How to launch a parent iOS App from its App Extension

后端 未结 7 1378
借酒劲吻你
借酒劲吻你 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:51

    I asked a similar question here: Communicating with/opening Containing app from Share extension. Basically, you can do a couple things.

    1. Use a UIWebView's loadRequest webView to load an NSURL request with your containing app's url. For example,

      NSURL *url = [NSURL URLWithString:@"myurl"];
      NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
      [self.webView loadRequest:request];
      
    2. Use a UIDocumentInteractionController and a custom file extension type to provide a link to your containing app (and your containing app only)

    3. Start a "fake" NSURL session to get the following functionality: In iOS, if your extension isn’t running when a background task completes, the system launches your containing app in the background and calls the application:handleEventsForBackgroundURLSession:completionHandler: app delegate method.

    The first one is probably your best bet.

提交回复
热议问题