Created the URL Types in info.plist
file and its URL scheme is http
. Created the NSUserActivity
Type. Created the entitlements, UIWebView
in 'ViewController' class. In AppDelegate
method I implemented below code:
func application (application: UIApplication,willContinueUserActivityWithType userActivityType: String) -> Bool {
let sharedUserActivityType = "com.test.testApp"
if (userActivityType == sharedUserActivityType) {
return true
}
return false
}
@available(iOS 8.0, *)
internal override func restoreUserActivityState(activity: NSUserActivity) {
//don't forget to call super!
if #available(iOS 8.0, *) {
super.restoreUserActivityState(activity)
let userInfo = activity.userInfo
} else {
// Fallback on earlier versions
}
}
func application(application: UIApplication, continueUserActivity
userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) ->
Void) -> Bool {
if userActivity == "com.test.testApp.view"
{
let mainListing = ViewController()
restorationHandler([mainListing])
}
if let window = self.window
{
window.rootViewController?.restoreUserActivityState(userActivity)
}
return true
}
func application(app: UIApplication, openURL url: NSURL, options:
[String : AnyObject]) -> Bool {
return true
}
I referred to link https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12-SW2
Created the json file named it apple-app-site-association
{ "applinks": { "apps":[], "details": { "teamId.com.test.testApp": { "paths":["*"] } } } }
I signed the apple-app-site-association file, but as I'm using iOS9 no need to sign.
I implement the method application:continueActivity and return YES.
- But my link is not opening in app, instead opening in safari.