【发布时间】:2017-07-07 15:16:47
【问题描述】:
我创建了一个新的urbanairship 帐户,并遵循了their link 中所述的所有文档,但是当我按照他们提到的那样设置AppDelegate 部分时:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let config = UAConfig.default();
UAirship.takeOff(config);
UAirship.push().defaultPresentationOptions = [.alert, .badge, .sound]
UAirship.push().userPushNotificationsEnabled = true;
return true;
}
我的代码在UAirship.push().defaultPresentationOptions = [.alert, .badge, .sound] 上崩溃说:fatal error: unexpectedly found nil while unwrapping an Optional value.
我调试并发现UAirship.push() 导致为零。
另请注意,我已按照同一页面上的要求创建了 AirshipConfig.pList 文件,并且我粘贴了以下内容:
<plist version="1.0">
<dict>
<key>developmentAppKey</key>
<string>Your Development App Key</string>
<key>developmentAppSecret</key>
<string>Your Development App Secret</string>
<key>productionAppKey</key>
<string>Your Production App Key</string>
<key>productionAppSecret</key>
<string>Your Production App Secret</string>
<key>useWKWebView</key>
<true/>
</dict>
谁能告诉我我在这里做错了什么?
【问题讨论】:
-
您是否已将
Your Development App ...占位符文本替换为您的实际应用程序密钥和秘密? (不要在此处粘贴它们 - 只需确认) -
感谢回复,没有,我真的不知道从哪里得到,请告诉我。
-
你关注这里的所有内容了吗:docs.urbanairship.com/engage/getting-started 并且你下载了他们的示例 iOS Swift 应用程序吗?
-
如果 UAirship 单例设置不正确,它将为零。遵循@DonMag 的建议,您应该一切顺利。
-
注意:Airship 的入职流程存在 UX 错误(截至 2019 年 5 月 16 日)。在完成“入门”教程之前,您可以查看应用程序密钥和秘密,但您需要这些才能成功发送推送通知,这是最后一步。要解决这个问题,只需点击发送按钮并单击“我收到通知”复选框。然后,您将能够访问仪表板,您可以在其中查看设置>API 和集成 中的键
标签: ios swift3 apple-push-notifications urbanairship.com