iOS Custom Url Scheme XCode -
first of all, know how make custom schemes in ios , know how open app website using javascript settimeout method.
i have app uses custom url scheme , working great. is, sends http://testsite.com/querystrings message other users in contact list (predefined) , on clicking web links in sms, these things happen:
- open link in safari
- open app if installed custom url using settimeout
- if not installed, move normal website page
what wanted open app directly sms if installed have send custom url scheme in sms, not option because if app not installed sms wont work weblink option now.
today, installed soundcloud , accidentally noticed thing when http:// m. soundcloud .com /... url sent in sms , on clicking link opens app (if installed) directly not safari (strange me).
so wondering how come app open web link without opening safari. googled around couldn't find solution problem. attaching screenshot mobile press , hold on link in messages app give open in "soundcloud" option well. how soundcloud registered http link handled automatically in app. please guys
the answer problem using associated domains (but after 9.2 have use universal links achieve this).
before universal links, primary mechanism open app when installed trying redirect app’s uri scheme (registered in app’s plist so) in safari. put routing logic in safari, there no way check if app installed or not.
ios 9 universal links intended fix this. instead of opening safari first when link clicked, ios check if universal link has been registered domain associated link, check if corresponding app installed. if app installed, opened. if it’s not, safari open , http(s) link load.
functionally, allows have single link either open app or open mobile site.
configure app register approved domains
- registered app @ developers.apple.com
- enable ‘associated domains’ on app identifier
- enable ‘associated domain’ on in xcode project
- add proper domain entitlement
- make sure entitlements file included @ build
configure website host ‘apple-app-site-association’ file
- buy domain name or pick existing
- acquire ssl certification domain name
- create structured ‘apple-app-site-association’ json file
- sign json file ssl certification
- configure file server
apple launched universal links in ios 9.0, moves app routing os developers don’t need worry doing routing in javascript.
receiving universal link url in app
uri schemes received deep link url through openurl in app delegate. universal links receive data via different code path: continueuseractivity. new delegate method used number of app transitions, ranging spotlight universal links, , see couple more use cases introduced in future os versions.
below snippet of code can use retrieve full universal link url opened app.
- (bool)application:(uiapplication *)application continueuseractivity:(nsuseractivity *)useractivity restorationhandler:(void (^)(nsarray *))restorationhandler { if ([useractivity.activitytype isequaltostring:nsuseractivitytypebrowsingweb]) { nsstring *myurl = [useractivity.webpageurl absolutestring]; // parse url string or access query params } return yes; }
source: https://blog.branch.io/how-to-setup-universal-links-to-deep-link-on-apple-ios-9
Comments
Post a Comment