Swapit has grown a lot over the past months. With our introduction of the Swapit Web Teasers, we actually also introduced an interface to invoke Swapit from any other third party app or from the web. Hence, it has always been possible to invoke Swapit from within your very own app, but we didn’t tell anyone yet.
WHAT CAN YOU DO?
Invoking Swapit means, a developer can integrate a functionality into his app, which allows the app to launch our Swapit app at a specific target. For example, Swapit can be launched in the
- Home Screen (i.e. the app’s main list that shows all products nearby)
- Item Detail Screen of a specific item
- Create Post Screen (so the user can start posting an item right away)
INVOKE THE SWAPIT APP VIA CUSTOM URI SCHEMA
If you know that Swapit is installed on the user’s phone, you can directly invoke the Swapit app by launching an Implicit Intent that directly invokes Swapit.
1) Main Screen: swapit://home
Here is an example for launching the Swapit home screen directly:
Intent i = Intent(Intent.ACTION_VIEW, Uri.parse("swapit://home"); startActivity(i);
2) Post Detail Screen: swapit://item/{id}
{id} … is the Swapit item ID in our Swapit database.
Here is an example for launching an item detail screen in Swapit directly:
Intent i = Intent(Intent.ACTION_VIEW, Uri.parse("swapit://item/5696381570252800"); startActivity(i);
3) Create Post Screen: swapit://post
Here is an example for launching the Swapit post item screen directly:
Intent i = Intent(Intent.ACTION_VIEW, Uri.parse("swapit://post"); startActivity(i);
INVOKE THE SWAPIT APP VIA WEB / HTTP
If you don’t know if the Swapit app is installed on the user’s device, it might make more sense to launch a web URL. If the Swapit app is installed on the user’s phone, the app will be invoked automatically. If Swapit is not yet installed on the user’s phone, the browser will be started and the user will be presented with the appropriate information.
1) Main Screen: http://app.swapit.la/home
If Swapit is not installed, the user will be directed to a website, which shows download instructions for Swapit. Content of the home screen can only be viewed inside the Swapit app.
Here is an example for launching the Swapit home screen:
Intent i = Intent(Intent.ACTION_VIEW, Uri.parse("http://app.swapit.la/home"); startActivity(i);
2) Post Detail Screen: http://items.swapit.la/{id}
If the Swapit is not installed, the user will be directed to the web teaser of the item requested. That web teaser contains some information about the item, but not everything. Download links to install Swapit are also be present on those web teaser pages. If Swapit is installed, starting this intent will automatically invoke Swapit and reveal all details about the item requested.
{id} … is the Swapit item ID in our Swapit database.
Here is an example for launching an item detail screen in Swapit:
Intent i = Intent(Intent.ACTION_VIEW, Uri.parse("http://items.swapit.la/5696381570252800"); startActivity(i);
3) Create Post Screen: http://app.swapit.la/post
If Swapit is not installed, the user will be directed to a website, which shows download instructions for Swapit. New items can only be posted from inside Swapit. Thus, Swapit needs to be installed to use this function.
Here is an example for launching the Swapit post item screen:
Intent i = Intent(Intent.ACTION_VIEW, Uri.parse("http://app.swapit.la/post"); startActivity(i);
Looks like a few typos in the code snippets..
i = Intent(Intent.ACTION_VIEW, Uri.parse(“swapit://hometartActivity(i);
I’m guessing should be..
i = Intent(Intent.ACTION_VIEW, Uri.parse(“swapit://home”));
startActivity(i);
LikeLike
I am not sure where you see that Paul, but it looks fine in the browser here 🙂
LikeLike
Pingback: Swapit Update: The License to Kill! | swapit blog