Reputation: 9273
I'm trying to open the app from the today extensions in the notification center, i have tried with the scheme url, but seems that i can't use is in the extensions, because:
[UIApplication sharedapplication]
doesn't work. how i can do?
Upvotes: 0
Views: 212
Reputation: 5327
Add button to the Storyboard in the extension
Add CFBundleURLSchemes so you can open app with url "weatherapp:"
Call openURL
@IBAction func buttonOpen_Action(sender: AnyObject) {
/*
Add to APP Info.plist
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>weatherapp</string>
</array>
</dict>
</array>
</dict>
</plist>
*/
let context = self.extensionContext
if let url = NSURL(string:"weatherapp:"){
context?.openURL(url, completionHandler: { (Bool) -> Void in
print("weatherapp:open done.")
})
}else{
print("ERROR: weatherapp: not supported")
}
}
Upvotes: 0
Reputation: 61
This should solve your problem:
NSURL *url = [NSURL URLWithString:@"testMe://"];
[self.extensionContext openURL:url completionHandler:nil];
Upvotes: 2