4

I struggled with dynamic links for days. Appreciate any help, please. I integrate firebase dynamic links, if I paste the link in chrome url and press enter, it can open app with event triggered and url passed but if I click the open button on the preview page, it always open App store regardless whether the app installed or not Any thoughts?

I have browsed all posts on the web, but no good luck.

"react-native": "^0.59.5"
"react-native-firebase": "^5.3.1"

pod 'Firebase/Core', '~> 5.20.1'
pod 'Firebase/DynamicLinks', '~> 5.20.1'

Domain on firebase console: https://links.umrgo.com/links

bundle id: com.umrgo.www.umr-app-ios

URL Types identifier: links.umrgo.com
URL Types identifier: com.umrgo.www.umr-app-ios


capabilities: applinks:links.umrgo.com

release build

I also add FirebaseDynamicLinksCustomDomains with a array of string https://links.umrgo.com

Some of my codes are as below.

   [FIROptions defaultOptions].deepLinkURLScheme = @"com.umrgo.www.umr-app-ios";

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
            options:(NSDictionary<NSString*, id> *)options
{
  BOOL handled = [[RNFirebaseLinks instance]
                  application:application
                  openURL:url
                  options:options
                  ] || [RCTLinkingManager
                        application:application
                        openURL:url
                        options:options
                        ];

  return handled;
}

- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
 restorationHandler:(void (^)(NSArray *))restorationHandler {
  BOOL handled = [[RNFirebaseLinks instance]
                  application:application
                  continueUserActivity:userActivity
                  restorationHandler:restorationHandler
                  ] || [RCTLinkingManager
                        application:application
                        continueUserActivity:userActivity
                        restorationHandler:restorationHandler
                        ];

  return handled;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  BOOL handled = [RCTLinkingManager
                  application:application
                  openURL:url
                  sourceApplication:sourceApplication
                  annotation:annotation
                  ];
  return handled;
}


const link = new firebase.links.DynamicLink(`https://www.umrgo.com/publish/${publishId}?publishType=${publishType}&publishId=${publishId}&otherUserUnionId=${currentUserUnionId}&conversationId=${conversationId}`,
        'links.umrgo.com/links').android.setPackageName(conf.GooglePackageName).ios.setBundleId(conf.AppleBundleId).ios.setAppStoreId(conf.AppleAppID);

firebase.links()
    .createShortDynamicLink(link, 'UNGUESSABLE')
    .then((url) => {
        var payload = {
            key: createLinkUniqueKey(conversationId, publishId, currentUserUnionId, publishType),
            url: url,
            publish_id: publishId,
            target_user_unionid: currentUserUnionId,
            conversation_id: conversationId,
            publish_type: publishType
        }
        axios.post(getApiEndpoint(conf.UMRApiUrls.createDynamicLinkRemote), payload, {
            headers: getAuthHeader()
        }).then(response => {
            console(response)
        })
    });

Some snapshots are below:

redirect to app store

ask for open app

enter link in browser and press enter

app open with url passed if enter link in browser

bottom right is the app, release build

Jinglu Zhou
  • 91
  • 2
  • 6
  • [redirect to app store](https://i.stack.imgur.com/CEYr2.jpg) [ask for open app](https://i.stack.imgur.com/dMz7y.jpg) [enter link in browser and press enter](https://i.stack.imgur.com/T3TbY.jpg) [app open with url passed if enter link in browser](https://i.stack.imgur.com/YiGGd.jpg) [bottom right is the app, release build](https://i.stack.imgur.com/aJsnP.jpg) – Jinglu Zhou May 21 '19 at 04:46
  • Some of my snapshot – Jinglu Zhou May 21 '19 at 04:51
  • Can you share a Dynamic Links URL? What is `url` in the callback after `createShortDynamicLink()`? – fphilipe May 21 '19 at 05:50
  • something like this https://links.umrgo.com/links/cXtQ2joM9CkbQomN6 – Jinglu Zhou May 21 '19 at 07:28
  • Make sure you've followed the [Receive Dynamic Links on iOS](https://firebase.google.com/docs/dynamic-links/ios/receive) guide. Also helpful is the debug view of the URL above: https://links.umrgo.com/links/cXtQ2joM9CkbQomN6?d=1 – fphilipe May 21 '19 at 07:53
  • I followed the firebase guide for ios, but I am using react-native firebase, so I don't take the AppDelegate.m part. – Jinglu Zhou May 21 '19 at 08:56
  • Looking into the debug graph, in the branching logic after I clicked open button, "App Installed?Use Universal Links", it always thinks the App is not there, I don't know why is that. The app is not published, but it's a release build. – Jinglu Zhou May 21 '19 at 09:00
  • Also, in the "use deep link", I inspect the html element, it's really just a normal website url, how is this supposed to open my App? "https://www.umrgo.com/publish/99135?publishType=real&publishId=99135&otherUserUnionId=o-K3P0l1Rk1LFb5HT9ne1wI_zLpE&conversationId=dummy_id" – Jinglu Zhou May 21 '19 at 09:01
  • Does the app open when you enter https://links.umrgo.com/links/cXtQ2joM9CkbQomN6 in the browser? Alternatively, try creating a note with that URL and then tapping on it. – fphilipe May 21 '19 at 09:26
  • If type in chrome address bar, and click enter button, it can open the app. If type in safari address bar and click enter button, nothing happens, just refresh the preview page. On both safari and chrome preview page, if I click the open button, it opens app store even if app is installed. One more thing, I noticed, if I click link in note, it pops up menu, if I choose open in app, it does open the app correctly, if I choose open in safari, it opens preview page. Next time I click the link in note, it doesn't prompt the choice menu, ios might memorize my choice. – Jinglu Zhou May 21 '19 at 21:58
  • 1
    Ok, I figured out. For anyone first try to test this feature, when you tap the link, you can choose to open in app or open in safari, if you choose open in app, everything looks good, however if you choose open in safari, the open button will always redirect to app store. – Jinglu Zhou May 22 '19 at 03:33
  • Please check my answer in this [post](https://stackoverflow.com/a/68472268/2530570), hope this will help you. – Pratik Patel Jul 21 '21 at 15:29

1 Answers1

0

You mentioned pasting link into a browser. If you do this in Safari, it will intentionally not go directly to your app because the device is assuming that your intent is to open a web page. If you tap on a link, it could act differently. It's possible that Chrome is following this same idea.

This answer provides some good testing steps to make sure it's working right: https://stackoverflow.com/a/44817701/2612222

Jay Whitsitt
  • 937
  • 9
  • 27