在ios中未接收Firebase云消息通知

在ios中未接收Firebase云消息通知,ios,firebase,unity3d,firebase-cloud-messaging,Ios,Firebase,Unity3d,Firebase Cloud Messaging,我在ios的应用程序中使用Firebase云消息通知,但当我测试真正的机器时,我发现我无法接收任何推送消息 我在ios上使用firebase unity软件包。 我检查了所有步骤,但我不知道问题出在哪里 我使用P8APNS文件,即keychain中的开发者标识和推送通知 在xcode中,我打开了选项(推送通知和后台模式),但它无法接收推送消息、后台或前台 以如下方式登录xcode控制台: [Firebase/Messaging][I-FCM002010] The subscription ope

我在ios的应用程序中使用Firebase云消息通知,但当我测试真正的机器时,我发现我无法接收任何推送消息

我在ios上使用firebase unity软件包。 我检查了所有步骤,但我不知道问题出在哪里

我使用P8APNS文件,即keychain中的开发者标识和推送通知

在xcode中,我打开了选项(推送通知和后台模式),但它无法接收推送消息、后台或前台

以如下方式登录xcode控制台:

[Firebase/Messaging][I-FCM002010] The subscription operation is suspended because you don't have a token. The operation will resume once you get an FCM token.

[GULReachability][I-REA902004] Network status has changed. Code:2, status:Connected


FCM: Initialize Firebase Messaging
FCM: Initialize Firebase Messaging

FCM: Retrieve registration token
FCM: Retrieve registration token

RequestPermissionAsync completed

[Firebase/InstanceID][I-IID003012] Provisioning profile has specifically provisioned devices, most likely a Dev profile.
[Firebase/InstanceID][I-IID003013] APNS Environment in profile: development
订阅操作已挂起,因为您没有 代币一旦获得FCM令牌,操作将恢复

您需要注册iOS客户端的FCM令牌

Firebase提供了有关设置的详细文档:

它的实质是将此代码包含在
AppDelegate
中:

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 })
} else {
  let settings: UIUserNotificationSettings =
  UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
  application.registerUserNotificationSettings(settings)
}

application.registerForRemoteNotifications()
然后你需要处理你得到的代币。您应该将此令牌存储在Firebase数据库中,然后在发送推送通知时需要将其包括在内


Firebase有一个发送推送通知的示例,其中包括用于存储这些令牌的数据库结构,位于此处:。

要成功订阅主题,必须首先请求
实例ID

FirebaseApp.configure()

UNUserNotificationCenter.current().delegate = self

let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(options: authOptions, completionHandler: {_, _ in })

application.registerForRemoteNotifications()

InstanceID.instanceID().instanceID { (result, _) in
    if result != nil {
        // Receive notifications from the "all" topic
        Messaging.messaging().subscribe(toTopic: "all")
    }
}

您在AppDelegate中设置了Firebase推送通知代码吗?我使用Firebase for unity软件包,只需设置以下Firebase.Messaging.FirebaseMessaging.TokenReceived+=OnTokenReceived;Firebase.Messaging.FirebaseMessaging.MessageReceived+=OnMessageReceived;[Firebase/InstanceID][I-IID003009]无法获取默认令牌错误域=nsurErrorDomain Code=-1005“网络连接已丢失”。新日志如下……我已完成所有设置,并且我的通知似乎正在工作,但我仍然收到该警告。