我正在使用testflight对我的应用和Firebase消息进行Beta测试以发送通知。
发送通知后,具有指定令牌的用户会收到通知,但是通过点击通知徽章,应用程序中的相关页面不会出现。就像didReceiveRemoteNotification
没有被调用一样。
我之前通过直接在移动设备上运行应用程序来测试通知,因此效果很好。
我将Debug Provisioning配置文件更改为Distribution,然后在Firebase中将APNs Authentication Key方法更改为APNs证书,但是仍然无法使用。
答案 0 :(得分:1)
我认为您没有在应用程序委托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()