Often the use cases and implementation around inter-app invites is overlooked. Handling it easily and well can be a bit subtle.

You have to deal with the situation if an intended recipient has the app installed. If they do not, you will want to do one thing. If they do have the app installed, then the invite notification should be handled in app. It becomes a bit of a chicken and egg problem — how does someone receive an invite if they don’t have the app installed?

Fortunately, there is a clever thing you can do for invites that handles both cases. It leverages a feature that both iOS and Android have: The ability to map an url to an app, so when the user taps that URL in email or sms (or a web-page) it starts the app if it is installed. This is called Deep Linking.

In Android this is done using deep linking and an intent filter in the manifest:

When Android detects that url, it will open up this activity. More details here: https://developer.android.com/training/app-indexing/deep-linking.html

In iOS 9+, this is done with universal links. Basically you include an apple-app-site-association file that describes what urls your app should open. For example:

Note: don’t append “.json” to the file.

See more details here.

Let’s talk about the use cases in a bit more detail and then walk through how these are solved using the feature I described above.

 

There are 4 use cases you need to consider:

1. Someone receives an invite who does not have the app installed

2. Someone receives an invite who does have the app installed.

3. Bulk invites, or outside of the app, inviting someone who may or may not have the app.

4. Someone uses the app to invite someone else who may or may not have the app.

 

The first are almost the same. It is just a matter where the SMS is sent from.

Bulk invites, or outside of the app, inviting someone who may or may not have the app:

1. The user’s information, name, phone number and possibly custom message, is captured and inserted into the database along with a unique identifier.

2. The website then generates an SMS with an url that contains the unique identifier as a parameter.

3. The SMS is sent. That’s it!

Someone uses the app to invite someone else who may or may not have the app:

1. The user selects a name from their contact list.

2. Optionally, they write a message for the receiving user.

3. The app then makes an authenticated rest call to the server, where the information is inserted into the database.

4. The rest call returns the unique id that was generated.

5. The app formats an url using the unique id, and then sends in in an SMS message to the recipient. That’s it!

 

A couple notes about this. In step 3, want the user to be authenticated so that someone couldn’t call the REST api directly and use it to spam. In step 5, the app sends the SMS. The server could send it, and in the future you may want it to, but if the app sends it then the user pays the SMS costs.

Someone receives an invite who does not have the app installed:

1. The user receives an SMS with a web url in it. The url has a unique id appended as a query parameter.

2. The SMS has a short message, asking them to click on the url for more information.

3. The user clicks on the url.

4. Since they don’t have the app installed the url starts the default browser and the visit the web page.

5. The web server, looks up the unique id, and retrieves the details of the invite such as the recipient’s name, or even a custom message. It also includes a link to Apple App Store or Google Play Market for downloading the appropriate app for their operating system.

Someone receives an invite who does have the app installed:

1. The user receives an SMS with a web url in it. The url has a unique id appended as a query parameter.

2. The SMS has a short message, asking them to click on the url for more information.

3. The user clicks on the url.

4. Since they have the app installed, and deep linking is enabled, the app is opened.

5. The app fetches the parameter from the url the performs a REST call to the server and looks up the details for the invite.

6. The app displays a screen with the details.

 

So there we have a basic way of sending invites users whether or not they have the app installed. However, if they have the app installed the will still be receiving SMS messages and the user has to click on it. That is at least two clicks just to get into the app.

1. Select the notification to open the SMS app.

2. Select the URL to open up our app. Depending on the operating system and version, there might be another step in there to verify that you want to open up the app.

 

It works though it is a bit clunky. Every time an invite is sent, the user will have to click on the link in the SMS. In a future blog post, we’ll see how to optimize this and make it better.