NSWidgetExtensionContext openURL Swift

后端 未结 4 1646
滥情空心
滥情空心 2021-01-12 15:08

I have been attempting to implement a button to open my iOS app from its widget. I realize this issue has been beaten to death on the forums but I cannot find explanation wi

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-12 15:50

    To open the Containing App from Todays Extension:

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

    You also need to add the following lines to the application's info.plist (open as a source code):

        CFBundleURLTypes
        
            
                CFBundleURLName
                com.mikitamanko.bubblewrap
                CFBundleURLSchemes
                
                    main-screen
                
            
        
    

    right after the

    
    
    
    
    

    Here's the complete guide how to open the app or share Users Defaults with Extension and the containing app.

提交回复
热议问题