Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launching App upon tapping Today Widget

Tags:

swift

I have just added a today widget to my app and I am trying to allow users to tap on the widget to launch it's containing app.

Basically at the moment I have a button over the top of my widget which is linked to this function:

    @IBAction func launchApp(sender: AnyObject) {
    var url: NSURL = NSURL.URLWithString("AppName://home")
    self.extensionContext.openURL(url, completionHandler: nil)
}

When I run the app and tap on the widget I get an alert view that states:

Unsupported URL - This URL wasn't loaded: AppName://home

Where am I going wrong?

like image 518
user3746428 Avatar asked Oct 20 '22 02:10

user3746428


1 Answers

To launch an app via URL you have to add a URL scheme to your app. The details of how to do that are found here

like image 178
jrturton Avatar answered Oct 23 '22 23:10

jrturton