gpt4 book ai didi

ios - iOS 中什么函数从 Firebase Messaging 接收推送通知?

转载 作者:行者123 更新时间:2023-11-30 12:33:45 25 4
gpt4 key购买 nike

一天前,我用来测试推送通知的 iPhone 可以接收推送通知,但由于某种原因,今天却没有。

当它工作时,我会调用完成处理程序以在此函数中显示通知:

@available(iOS 10, *)
extension AppDelegate : UNUserNotificationCenterDelegate {

func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
completionHandler([.alert, .badge, .sound])
}

但是,该函数似乎不再被调用。我看到打印任何内容的唯一函数是这个:

extension AppDelegate : FIRMessagingDelegate {
// Receive data message on iOS 10 devices while app is in the foreground.
func applicationReceivedRemoteMessage(_ remoteMessage: FIRMessagingRemoteMessage) {
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
print(remoteMessage.appData)
}
}

我从Firebase Send a Notification to an iOS Device docs获得了所有这些功能。我真正想要的只是能够从 Apple 的 APNs 服务器接收推送通知。我在控制台中收到此行 APNs token returned: 32 bytes 并且推送通知昨天还在工作,所以我不确定为什么它停止了。

我怀疑让它停止工作的唯一原因是我删除了该应用程序并将其重新安装到 iPhone 上,除此之外我根本没有弄乱 AppDelegate 中的代码。有人可以帮我弄清楚为什么我的推送通知可能已停止发送吗?

请注意,我正在使用 Firebase Messaging topics 从我的云函数发送这些消息,我可以确认,当我在上面的第二个函数中接收消息时,它正确发送了消息,只需不像昨天收到的第一个。我正在使用 admin.messaging().sendToTopic(pet_Id, Payload, options); 发送通知。

这是我的 full AppDelegate.swift file ,如果有人能帮助我解决这个问题,我将不胜感激!

最佳答案

我也有类似的情况,

这是我的答案 - Firebase Push Notifs Problem

这可能是问题所在,

我关闭了推送并从苹果开发中心删除了证书,然后重新创建了它们,这使得一切正常工作。

我也将这行代码设置为,

FIRInstanceID.instanceID().setAPNSToken(deviceToken as Data, type: FIRInstanceIDAPNSTokenType.sandbox)

当我推送到应用商店时,我会将其更改为 .prod。”

关于ios - iOS 中什么函数从 Firebase Messaging 接收推送通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43133656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com