How to launch a parent iOS App from its App Extension

后端 未结 7 1374
借酒劲吻你
借酒劲吻你 2021-02-07 07:22

Does any one know how to launch the parent app from the app extension\'s view controller?

I just want to launch the main app from its app extension.

7条回答
  •  [愿得一人]
    2021-02-07 07:50

    Here is another way to do it:

    1. Step 1 from here
    2. Select extension target and go to its Build Settings. Set Require Only App-Extension Safe API to NO.
    3. Use UIApplication.shared.openURL(URL(string:"openPdf://")!) as you normally would do it outside extension to open urls.

    Note, that you'll get 'openURL' was deprecated in iOS 10.0 warning. So this looks like it is not guaranteed to work in future.

    Consider using local Notifications to wake up host app instead of this.

提交回复
热议问题