49

I'd like to be able to open the app and print the parameters when I click on the dynamic link (even though it's not published).

Is there a way to do this?

skywinder
  • 21,291
  • 15
  • 93
  • 123
TIMEX
  • 259,804
  • 351
  • 777
  • 1,080
  • Have you seen this [answer](http://stackoverflow.com/a/38736094/4625829) before? Maybe implement the same and just include some logs where you need them? – AL. Sep 22 '16 at 03:44

2 Answers2

102

Yes! In fact, I go through this exact process in the getting started videoS (part 1), (part 2), which I recommend you check out if you haven't yet.

But, generally speaking, you can test the "Open my app if I have it installed" flow simply by clicking on a dynamic link. If your app is installed on the device, it should open up just fine; even if it's not a published app.

If you want to test the non-installed flow, this is pretty easy, too.

  • First, give your Firebase project an app store ID in your project settings. It can be any valid App store ID -- it doesn't have to be for your app.
  • Then generate a new dynamic link.
  • This time, when you click on this new link, it should take you to the app store for the ID you listed above. You don't need to actually install this app -- just making it to the app store listing is good enough.
  • Now, go ahead and reinstall and run your app. If everything is working properly, it should retrieve and display the dynamic link data for you.
Sergey Mell
  • 7,780
  • 1
  • 26
  • 50
Todd Kerpelman
  • 16,875
  • 4
  • 42
  • 40
  • 7
    Thanks a lot- it worked as expected. Minor addition: for quick testing, you dont even need App store Id- just click on dynamic link, it would go to play store and show "Item not found". Next simply install your app- it will automatically receive the link from intent and behave as though link was pressed.. – Apporve Chandra Mar 10 '17 at 07:59
  • 4
    This is a nice way to test the non-installed flow. I found out that when the app is installed the method `application: UIApplication, continue userActivity: NSUserActivity, restorationHandler` is called but when the app is NOT installed the method `app: UIApplication, open url: URL, options` is called. @Todd Kerpelman is that correct? – Tom Spee Mar 27 '19 at 08:59
  • Perfect answer! – Vishwas Singh Dec 24 '19 at 12:28
  • @Tom Spee's comment also helped here.. +1 – Abhinav Dobhal Jul 21 '20 at 13:42
  • @Todd, When we click on dynamic link Scenario 1 : When app installed :: We get URL properly. Scenario 2 : when the app is NOT INSATLLED, we get the URL as NULL. How to get this in this situation? code reference screenshot https://prntscr.com/vfz4jj – Rohit Mandiwal Nov 09 '20 at 08:57
  • Make sure to add `FirebaseApp.configure()` inside`didFinishLaunchingWithOptions` or app will open, but the dynamic links will not be handled. – regina_fallangi Aug 04 '21 at 10:26
  • Is this solution also working for Android and the Play store? – D0m3 Mar 24 '22 at 16:30
  • any idea how can we test the no-installed flow for android? – haythem souissi Apr 20 '22 at 13:37
  • @D0m3 did you find any way to test the same on android? – Himanshu Apr 21 '22 at 03:13
  • I tried this and I just get "CapacitorFirebaseDynamicLinks.handleLink() - Dynamic link has no url" – MadMac May 03 '22 at 20:08
  • 1
    Ah! It only works if the preview page is enabled. https://github.com/firebase/firebase-ios-sdk/issues/1244#issuecomment-502469160 – MadMac May 03 '22 at 21:16
2

I have faced the same issues, and after spending many hours trying to found a solution, and following the instruction to debug explained by Todd Kerpelman post, I could identify that the firebase has not sent a universal link on the first app launch and has sent the scheme URL with the following structure:

[bundle_id]://google/link/?deep_link_id=[firebase_universal_link]

After identifying that, I found the dynamicLinkFromCustomSchemeURL method inside of the Firesabe SDK and I could solve my problem on the first app launch by dynamic links.

/**
 * @method dynamicLinkFromCustomSchemeURL:
 * @abstract Get a Dynamic Link from a custom scheme URL. This method parses URLs with a custom
 *     scheme, for instance, "comgoogleapp://google/link?deep_link_id=abc123". It is suggested to
 *     call it inside your |UIApplicationDelegate|'s
 *     |application:openURL:sourceApplication:annotation| and |application:openURL:options:|
 *     methods.
 * @param url Custom scheme URL.
 * @return Dynamic Link object if the URL is valid and has link parameter, otherwise nil.
 */
- (nullable FIRDynamicLink *)dynamicLinkFromCustomSchemeURL:(NSURL *)url
    NS_SWIFT_NAME(dynamicLink(fromCustomSchemeURL:));

/**
 * @method dynamicLinkFromUniversalLinkURL:completion:
 * @abstract Get a Dynamic Link from a universal link URL. This method parses the universal link
 *     URLs, for instance,
 *     "https://example.page.link?link=https://www.google.com&ibi=com.google.app&ius=comgoogleapp".
 *     It is suggested to call it inside your |UIApplicationDelegate|'s
 *     |application:continueUserActivity:restorationHandler:| method.
 * @param URL Custom scheme URL.
 * @param completion A block that handles the outcome of attempting to get a Dynamic Link from a
 * universal link URL.
 */
- (void)dynamicLinkFromUniversalLinkURL:(NSURL *)url
                             completion:(FIRDynamicLinkUniversalLinkHandler)completion
    NS_SWIFT_NAME(dynamicLink(fromUniversalLink:completion:));

/**
 * @method dynamicLinkFromUniversalLinkURL:
 * @abstract Get a Dynamic Link from a universal link URL. This method parses universal link
 *     URLs, for instance,
 *     "https://example.page.link?link=https://www.google.com&ibi=com.google.app&ius=comgoogleapp".
 *     It is suggested to call it inside your |UIApplicationDelegate|'s
 *     |application:continueUserActivity:restorationHandler:| method.
 * @param url Custom scheme URL.
 * @return Dynamic Link object if the URL is valid and has link parameter, otherwise nil.
 */