已收到testflight中的通知,但不起作用

时间:2019-05-03 19:54:56

标签: swift firebase-cloud-messaging apple-push-notifications

我正在使用testflight对我的应用和Firebase消息进行Beta测试以发送通知。

发送通知后,具有指定令牌的用户会收到通知,但是通过点击通知徽章,应用程序中的相关页面不会出现。就像didReceiveRemoteNotification没有被调用一样。

我之前通过直接在移动设备上运行应用程序来测试通知,因此效果很好。

我将Debug Provisioning配置文件更改为Distribution,然后在Firebase中将APNs Authentication Key方法更改为APNs证书,但是仍然无法使用。

这是AppDelegate。 appdelegate

1 个答案:

答案 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()