Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSWidgetExtensionContext openURL Swift

I have been attempting to implement a button to open my iOS app from its widget. I realize this issue has been beaten to death on the forums but I cannot find explanation with the specific error I am receiving. Perhaps some of you more experienced iOS developers can shed some light on this.

I am developing an update to one of my iOS apps for iOS 10 using XCode 8.1 and Swift 2.

Code for my widget's button: enter image description here

URL scheme added to the widget's info.plist: enter image description here

The runtime error I receive when pressing the OpenApp button:

AppWidget[11872:3577323] __55-[_NCWidgetExtensionContext openURL:completionHandler:]_block_invoke failed: Error Domain=NSOSStatusErrorDomain Code=-10814 "(null)"

// Note: app name has been substituted with appropriate generics.

like image 884
JRystedt Avatar asked Nov 05 '16 15:11

JRystedt


1 Answers

I often find the OS Status lookup site pretty useful to infer details from errors. An OS error with code -10814 is a kLSApplicationNotFoundErr, which describes the scenario when:

No application in the Launch Services database matches the input criteria.

It sounds like your application has not been properly registered with the system as a consumer of the URL scheme you are using. Have you double-double (double!) checked that the bundle identifier and URL scheme match? Have you verified that your app can be launched with the URL from Safari?

like image 161
Kasper Munck Avatar answered Sep 18 '22 11:09

Kasper Munck