0

在文件中创建了 URL 类型info.plist,其 URL 方案为http. 创建了NSUserActivity类型。UIWebView在“ViewController”类中创建了权利。在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
}
4

1 回答 1

1

您的 apple-app-site-association JSON 文件格式不正确 - 详细信息字典中缺少 appID 键,即

{ 
  "applinks": 
   { "apps":[], 
     "details": [
       {
         "appID": "teamId.com.test.testApp",  
         "paths":["*"] 
      } 
     ]
    } 
}

您可以在以后使用Apple 验证工具进行验证。

还要注意,即使您使用的是 iOS9,您仍然需要通过 https 提供 apple-app-site-association 文件。

于 2016-01-25T14:53:18.747 回答