gpt4 book ai didi

iOS Firebase 推送通知未出现

转载 作者:可可西里 更新时间:2023-11-01 02:04:19 24 4
gpt4 key购买 nike

我已根据此演练设置了推送通知:https://www.appcoda.com/firebase-push-notifications/

但是当我从 Firebase 发送测试消息时,它没有显示。我遵循了所有步骤,我有有效的证书:

enter image description here

为推送通知设置配置文件:

enter image description here

在我的 App ID 下,它显示通知已启用:

enter image description here

我已将证书上传到 Firebase:

enter image description here

在我的 AppDelegate didFinishLaunchingWithOptions 中:

    if #available(iOS 10.0, *) {
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
// For iOS 10 data message (sent via FCM
FIRMessaging.messaging().remoteMessageDelegate = self
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}


application.registerForRemoteNotifications()

连同 AppDelegate 中的 Firebase 回调方法:

func applicationReceivedRemoteMessage(_ remoteMessage: FIRMessagingRemoteMessage) {
print(remoteMessage.appData)
}

显然我已经导入了:

import UserNotifications
import FirebaseInstanceID
import FirebaseMessaging

我不确定为什么推送通知不起作用,似乎一切都已到位。我做的唯一不寻常的事情是从目标 -> 代码签名中删除了权利,因为当我尝试运行该应用程序时它给我一个无效的权利错误。现在它已被删除,应用程序运行良好。关于那个单独的问题,我确实有一个悬而未决的问题,但现在我假设这不是我这里出现问题的原因。

只是为了确认一下,我不必在添加通知后重新下载 Google plist?在添加通知之前,我在我的项目中使用了 Firebase,所以我已经有了一个。

感谢您帮助通知正常工作!

最佳答案

尝试在您的 info.plist 中添加 FirebaseAppDelegateProxyEnabled 类型“Boolean”值“NO”

并可能在您的 AppDelegate 中将 Messaging.messaging().shouldEstablishDirectChannel 添加到 true

关于iOS Firebase 推送通知未出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44416272/

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