Open the main application through today's extension

I implemented the widget added today in my application. Today's extension includes a UITableView. Now I would like to open the application if the UITableView cell was clicked. Do any of you know how to do this?

+4
source share
2 answers

Today extensions have access to NSExtensionContext which allows you to open the application . In the expansion controller:

 let myAppUrl = NSURL(string: "myapp://some-context")! extensionContext?.openURL(myAppUrl, completionHandler: { (success) in if (!success) { // let the user know it failed } }) 

A success parameter is provided because the system may not open a specific URL (let's say you want to run twitter: //, but the user does not have the Twitter application installed. If you run your own application, this should not be a problem.

+5
source

The provided Christopher Pickslay code works fine, you just need to add the following lines to the info.plist application (open as source):

  <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>com.mikitamanko.myapp</string> <key>CFBundleURLSchemes</key> <array> <string>some-context</string> </array> </dict> </array> 

right after

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> 

Here is a complete guide on how to open the application or share default users with the extension and containing the application.

+2
source

All Articles