user3746428
user3746428

Reputation: 11175

Launching App upon tapping Today Widget

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?

Upvotes: 5

Views: 2127

Answers (1)

jrturton
jrturton

Reputation: 119242

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

Upvotes: 3

Related Questions