简体   繁体   中英

universal links not working swift 3

I have implemented universal links in my app with following steps :-

  • turn on app domains in certificate and create provisioning file
  • install certificate and provisioning profile
  • turn on associated domain in capabilities
  • enter the link on which I have to perform universal links with format (applinks:www.xxxxxxx.com)
  • cross verifies on .entitlements file
  • In identity and type of entitlement file, target membership box has been selected
  • txt file has been uploaded on server with format :-

    {"applinks": {"apps": [], "details": [{"appID": “teamId.com.abcd.efgh”, "paths": ["*"]}]}}

  • checked the site with validation which shows

    a) apple validator enter image description here

    b) aasa-validator enter image description here

  • Implemented the function in my appDelegate but it is never called

    func application(_ application: UIApplication, continue userActivity: NSUserActivity,restorationHandler: @escaping ([Any]?) -> Void) -> Bool {}

My universal link is not working I am not able to redirect my app from links in notes or from any place. I have implemented all the neccessary steps I know. I am not able to debug the issue.

Your AppDelegate implementation is not complete yet, you need to get your url from the received NSUserActivity object as declared here in apple documentations, use following method to complete your appDelegate implementation:

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {

        guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
            let url = userActivity.webpageURL

            else
        {return false}

        return true
}

Then, you can use this url and send it to whatever ViewController want to load it in. Hope this helps;)

You mentioned it as txt file but it should be a file with no extension and the name of the file should be " apple-app-site-association " and it must be present in root directory or .well-known directory in your server.

Check this article:

https://developer.apple.com/documentation/xcode/supporting-associated-domains

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM