0

I am implementing firebase dynamic links in my iOS app and I can already parse the link, redirect to AppStore etc. Now I want to distinguish the first run of the app, when user installs it from the dynamic link - I want to skip the intro and show him the content that is expected to be shown.

Is there a way to know how the app is opened before being in didFinishLaunchingWithOptions?

KENdi
  • 7,576
  • 2
  • 16
  • 31
muyat
  • 57
  • 3
  • 13

1 Answers1

1

The method application:openURL:options: will be called when Firebase Dynamic Links iOS SDK finished retrieving the pending (deferred) dynamic link. If pending dynamic link is found, the object [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url] will have non-nil property url. The url will be equal to your deep link, that user tapped while your App was not installed. If link is not found, this property will be nil.

I suggest you to show "loading screen" in your didFinishLaunchingWithOptions. When Firebase Dynamic Links SDK will pass you result, you can proceed with custom onboarding if pending dynamic link is found. Or default onboarding if pending dynamic link is not found. Keep in mind, if network is slow, this may take some time. You may want to have timeout set to X seconds, to not hold your user too long at "loading screen".

Documentation about receiving Firebase Dynamic Links on iOS https://firebase.google.com/docs/dynamic-links/ios/receive

Oleksiy Ivanov
  • 2,454
  • 15
  • 21
  • Ivanow "When Firebase Dynamic Links SDK will pass you result, you can proceed with custom onboarding if pending dynamic link is found. Or default onboarding if pending dynamic link is not found." But how can I know if pending dynamic link is found if the openURL will never be called? Because not always is the app being opened/downloaded with a dynamic link. I really hope you can help me out with this one, thanks. – muyat Nov 28 '17 at 08:19
  • @muyat openURL will be called even if pending link is not found. You will receive link may look similar to "://google/link/?dismiss=1&is_weak_match=1". See this comment https://github.com/firebase/firebase-ios-sdk/issues/233#issuecomment-331533695 I am working on improving documentation to make this clear. Please comment if you do not see openURL: called as described in this answer. – Oleksiy Ivanov Nov 29 '17 at 18:52
  • @Ivanow Thank you for your response. I will try to implement this and let you know if all worked out for me! Thanks again. – muyat Dec 06 '17 at 08:55
  • @Ivanow When the loading screen is finished I alreay need to know if the app is opened with an dynamic link or not. Delaying the launching screen isn possible but for how long? 2, 3 or maybe 5 seconds? Hope to hear from you! – muyat Dec 07 '17 at 13:01
  • By "loading screen" I mean your own subclass of UIViewController that will display information like your App logo and UIActivityIndicator. You can keep this view controller on screen for whatever time you want and your App will not be killed. – Oleksiy Ivanov Dec 07 '17 at 20:05
  • @Ivanow Thank you for your help sir. I got one last question maybe you can help me out with this one. When I click on a dynamic link I will be redirected to the appstore and from there I download the app. What I really need is the long link of the dynamic link because I got data in it which I need to extract. This method will be opened when I start the app for the first time: -(Bool)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDICtionarryoptions). In continueuseractivty anables me to do this "useractivity.webpageURL" I need the same in the other method. – muyat Dec 08 '17 at 13:21
  • This question https://stackoverflow.com/questions/47714987/how-to-get-long-link-from-dynamic-link-when-opening-app-for-the-first-time ? Not sure what you asking? FIRDynamicLink object do not contains data you need, like missing some stuff that present in long link? Can you put all that you need to deep link, FIRDynamicLink.url ? – Oleksiy Ivanov Dec 08 '17 at 17:53
  • Ivanow I have created a dynamic link in firebase. From the dynamic link I took the long like so I could add parameters to it. So whenever someone clicks on it, they first need to download the app and when they open the app, I want to take the data from the parameters which I put in there myself. With that data I need to do things. So the method that is being opened only gives me the URL but not the full url / long link. – muyat Dec 08 '17 at 20:11
  • @Ivanow You said you can place data in the deeplink, but how? I only know about placing data in the long link of the dynamic link. – muyat Dec 08 '17 at 20:13
  • @Ivanow The long link looks like this : https://abc123.app.goo.gl/?link=https://example.com&d=1 and the link i get looks like this : www.google.nl/test. In the openURL I have access too the long link but that method is not being called when I need it (When someone opens app for the first time). – muyat Dec 08 '17 at 20:15
  • @Ivanow I don't only want to make 1 deeplink with data. But I need to make many of them. That is why I need to add parameters to a long link whenever I need a link. – muyat Dec 08 '17 at 20:31
  • @Ivanow I am building a feature where I can send people an invitation email with a link in it. That link got their email, first and lastname as parameter/extra data. When they click on it they will be redirected too the app and afther they download the app, I will extract the data and use it to automatically create an accoutn for that person. That is the feature that I want to make using dynamic link. Long links are editable so I wanted to use it to store data in it. – muyat Dec 08 '17 at 20:46
  • Added answer there https://stackoverflow.com/questions/47714987/how-to-get-long-link-from-dynamic-link-when-opening-app-for-the-first-time/47723098#47723098 – Oleksiy Ivanov Dec 08 '17 at 22:31