NSWidgetExtensionContext openURL Swift [英] NSWidgetExtensionContext openURL Swift
问题描述
我一直在尝试实现一个按钮,以从其小部件中打开我的iOS应用程序.我知道这个问题在论坛上被打死了,但是我找不到我收到的特定错误的解释.也许你们中一些更有经验的iOS开发人员可以对此有所启发.
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.
我正在使用XCode 8.1和Swift 2开发针对我的iOS 10的iOS应用的更新.
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:
URL方案已添加到小部件的info.plist中:
URL scheme added to the widget's info.plist:
按下OpenApp按钮时收到运行时错误:
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.
推荐答案
我经常找到操作系统状态查询网站从错误中推断细节非常有用.代码为-10814
的OS错误是kLSApplicationNotFoundErr
,它描述了以下情况的情况:
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:
Launch Services数据库中没有应用程序符合输入条件.
No application in the Launch Services database matches the input criteria.
听起来您的应用程序未正确注册为所使用URL方案的使用者.您是否进行过两次double-double(double!)检查包标识符和URL方案是否匹配?您是否已验证可以使用Safari中的URL来启动您的应用?
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?
这篇关于NSWidgetExtensionContext openURL Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!