Reputation: 95
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.
Upvotes: 0
Views: 368
Reputation: 775
Your apple-app-site-association JSON file is in the incorrect format - appID key is missing within the details dictionary, i.e.
{
"applinks":
{ "apps":[],
"details": [
{
"appID": "teamId.com.test.testApp",
"paths":["*"]
}
]
}
}
You can use the Apple verification tool to verify this in future.
Note as well even if you are on iOS9 you still need to serve the apple-app-site-association file via https.
Upvotes: 1