2

I have to create an iOS app, which needs to know a referral code right after the installation. The code comes from an email or from a link in the browser. The goal is to make the app have the referral code no matter it is already installed on the user's device or it is being installed by the clicking of the link.

What I know already:

  • I have to register an URL scheme with my app, for example myapp://
  • I have to handle opening by this URL, recognizing the referrer code from it (myapp://refcode=123)
  • I have to have a web service, which detects (with JavaScript) if the user's device can handle my URL scheme or not (like this: https://stackoverflow.com/a/6599773/511878)
  • If the app is not installed, I can send the user to the App Store to download it, otherwise I can open the app by this URL and transfer the information into it

What I miss: How can I immediately call this URL after installation?

I was sure this is impossible to do until this morning, when I've found that Apple's TestFlight is doing exactly the same. I've got an email containing an invite to some app, clicked on the link, and because I did not have TestFlight installed on that device so far, it brought me to the App Store, where I clicked install. The device installed TestFlight app. After this I've clicked the Open button in the Store, which immediately showed the invite for me.

I think the solution can't be that it recognized me, and picket up the invite from the server based on my user account, because I might have multiple invites, so it had to know which exact one to show.

EDIT: Video of this happening: http://gk.lka.hu/x/tf.mov

So the question is: How can I transfer information into an app which is being installed after a link is clicked without reclicking the link?

Community
  • 1
  • 1
gklka
  • 2,459
  • 1
  • 26
  • 53
  • I don't think you can. Did it show the invite only after you logged in? – Wain Jan 06 '15 at 07:37
  • Nothing can detect that if your app has just been installed, except your app. Best is to have a webservice which will get called when you first launch the app, you can use NSUserDefault to save the referral code, and for checking whether its your first launch. – iphonic Jan 06 '15 at 07:37
  • @Wain: No, I did not have to log in or do anything, the app opened with the invite right after launching it. – gklka Jan 06 '15 at 08:05
  • I've uploaded a video showing the TestFlight thing. – gklka Jan 06 '15 at 08:10
  • FWIW, I don't think TestFlight is a real app - it's a webclip. – Mike M Jan 06 '15 at 12:56
  • @MikeM: Yes, it was a webclip until Apple bought it recently. Now you can download an all-native app from the App Store. – gklka Jan 06 '15 at 12:58

1 Answers1

1

I'm a developer at Branch and we recently built this system for others to use. If you want to build a similar system from scratch, here is an example of what you'll have to do:

  1. The web service you described above must capture some information from the user, such as IP address, OS, OS version, screen size, etc., before redirecting to the App Store. It should associate this with the link that was clicked, or at least the refcode from the link (http://yoursite.com/redirect?refcode=123).

  2. After your app is downloaded, the first time it opens, send up the same info (IP Address, OS, etc.) up to your server. If your server sees these params and that they're the same as what you grabbed in step 1, it should pass back refcode=123 to your app.

  3. Your app should then handle the 123 refcode however you see fit (e.g. open to the appropriate view controller, apply the referral code, etc.).

Hopefully that helps. It's definitely harder than it sounds to build from scratch..

st.derrick
  • 4,769
  • 2
  • 24
  • 25