I've implemented universal links in my application as well as server side. Everything works fine when the app is installed. If the app is not installed on the device and I click on the universal link from say notes or mail, I'm redirected to the app store from where I can download the app. On download completion however, if I click 'OPEN' in the app store page, the app delegate method below is not called:
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler
As a result, I cannot perform certain actions in response to the userActivity.webpageURL
that I would normally get when the app is running or previously installed on a device. Is this normal behaviour? i.e. If the app is not installed, the Universal link will only serve as a medium to install the app from the app store?
xcrun supports opening URLs on iOS simulator as if they have been triggered by a user action. So if you're having all your USB ports plugged in with other stuff like me, you can test universal links on iOS simulator using xcrun!
All you have to do is tell the app which scheme would you like to use. For this just Open Xcode, got to Project Settings -> Info, and add inside 'The URL Types” section a new URL scheme. Add something of the sort of com. myApp and that's it.
To support universal links in your app: Create a two-way association between your app and your website and specify the URLs that your app handles. See Supporting associated domains. Update your app delegate to respond when it receives an NSUserActivity object with the activityType set to NSUserActivityTypeBrowsingWeb .
That's exactly how universal links are supposed to work. If the user didn't have your app, the download is a brand new session instead of a continued user activity.
I believe branch.io offers an SDK that allows for continuity for new installs.
Edit:
Ok, I did some digging and this is called deferred deep linking. It's not officially supported by Apple Universal links.
But here's basically how branch does it:
Here's a more detailed article about all the linking types in iOS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With