Skip to content

Instantly share code, notes, and snippets.

@talkol
Last active July 19, 2016 08:59
Show Gist options
  • Save talkol/0131e2274a887a705e276dd84c04bf65 to your computer and use it in GitHub Desktop.
Save talkol/0131e2274a887a705e276dd84c04bf65 to your computer and use it in GitHub Desktop.
  1. Create a web page that the user will visit (with Safari) before being sent off to Apple App Store
  2. This web page will save a cookie with the value you want in INSTALL_REFERRER
  3. Then redirect to the App Store, user downloads and installs the app
  4. App opens SafariViewController (can be hidden with some tricks) and the web page opened inside has access to the same cookie
  5. The web page in SafariViewController opens a standard URL scheme to communicate back with the app
  6. The app receives the parameter via the URL scheme in AppDelegate

Note that this assumes that the original web page was opened in Safari, if it was opened in some 3rd party app, you're out of luck. There's no 100% accurate method that I know, only heuristic ones in this case.

@geldarhb
Copy link

We used this trick on AppMyDay as well and it worked like a charm. You should be careful with explicitly launching Safari to grab your cookie - Apple did not like the fact we're doing that (they defined it as bad UX for the users) and rejected our app until we removed this flip-flop behaviour.

@oriharel
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment