在info.plist
文件中创建了URL类型,其URL方案为http
。创建了NSUserActivity
类型。在'ViewController'类中创建了权限UIWebView
。我在AppDelegate
方法中实现了以下代码:
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
}
创建了名为apple-app-site-association
的json文件{
"applinks":
{
"apps":[],
"details":
{
"teamId.com.test.testApp":
{
"paths":["*"]
}
}
}
}
我签署了apple-app-site-association文件,但由于我正在使用iOS9,因此无需签名。
我实现了方法应用程序:continueActivity并返回YES。
答案 0 :(得分:0)
您的apple-app-site-association JSON文件格式不正确 - 详细信息词典中缺少appID密钥,即
{
"applinks":
{ "apps":[],
"details": [
{
"appID": "teamId.com.test.testApp",
"paths":["*"]
}
]
}
}
您可以在将来使用Apple verification tool进行验证。
即使您使用的是iOS9,也需要注意,您仍然需要通过https提供apple-app-site-association文件。