Today App Extension Widget Tap To Open Containing App

前端 未结 5 1161
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 15:36

I\'ve implemented a Today widget for my application +Quotes which displays the day\'s quote within the notification center with the help of these Apple Docs. What I\'d like

5条回答
  •  爱一瞬间的悲伤
    2020-12-02 16:07

    Just in case, here's the version for Swift 3 with the error handling version:

    let myAppUrl = URL(string: "main-screen:")!
    extensionContext?.open(myAppUrl, completionHandler: { (success) in
        if (!success) {
            print("error: failed to open app from Today Extension")
        }
    })
    

    To make it work you need to open Application's info.plist (open as source code) and in the very top, after this

    
    
    
    
    

    add the following, so the App will know which URLs it should handle Here's the complete example of how to open the containing app and share User Defaults between app and Extension.

提交回复
热议问题