swift - 已收到测试飞行中的通知但无法正常工作
问题描述
我正在使用 testflight 测试我的应用程序和 Firebase 消息以发送通知。
发送通知时,具有指定令牌的用户会收到通知,但通过点击通知徽章,应用程序中的相关页面不会出现。就像didReceiveRemoteNotification
不叫。
我之前在手机上测试过通知,直接在手机上运行应用程序,效果很好。
我将调试配置文件更改为分发并在 Firebase 中将 APNs 身份验证密钥方法更改为 APNs 证书,但它还不起作用。
解决方案
我认为您没有在 app delegate 中检查授权didFinishLaunchingWithOptions
。
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions) { (accepted, error) in
if !accepted{
CLog.i("Notification not accepted!")
}
}
UIApplication.shared.registerForRemoteNotifications()
推荐阅读
- dataflow - 什么是“数据流作业似乎被卡住了,因为在过去 1 小时内没有看到任何工作人员活动”?
- pandas - 此时我似乎无法安装任何东西
- android - 如何从 Unity 创建前台服务
- php - 如何在不使用 phpWord 或任何其他包的情况下仅使用核心 php 获取仅写入文档(.doc、.docx、.pdf)中的内容
- generics - 带有 kotlin 泛型的 Moshi 为接口抛出 No JsonAdapter
- r - 使用 EDGAR 在 R 中的 For-Loop 中创建变量的问题
- javascript - 将 Electron 应用程序打包到 macOS 时出错
- c - 蜂鸣器 持续蜂鸣 HIGH 然后 LOW
- java - 如何在Android中将HTML页面下载为pdf?
- opencv - 获得清晰和连续轮廓opencv的问题