在iOS中未收到Firebase Cloud Messaging通知

时间:2018-08-31 15:04:25

标签: ios firebase unity3d firebase-cloud-messaging

我在ios的应用程序中使用Firebase Cloud Messaging Notification,但是在测试真实计算机时,发现我无法收到任何推送消息。

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

我在推送通知中使用p8 APNs文件,开发者身份。

在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

2 个答案:

答案 0 :(得分:0)

  

由于您没有订阅服务,因此该订阅操作已被暂停   令牌。收到FCM令牌后,操作将恢复。

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

Firebase具有用于设置此功能的详细信息文档:Setting Up a Firebase Cloud Messaging Client App on iOS

它的实质来自于将此代码包含在您的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有一个用于发送推送通知的示例,其中包括一个用于存储这些令牌的数据库结构,位于以下位置:Send Firebase Cloud Messaging notifications for new followers

答案 1 :(得分:0)

要成功订阅主题,您必须先请求$rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF; $rendererLibraryPath = dirname(__FILE__) . '/mpdf'; if (!PHPExcel_Settings::setPdfRenderer( $rendererName, $rendererLibraryPath )) { die( 'NOTICE: Please set the $rendererName and $rendererLibraryPath values' . '<br />' . 'at the top of this script as appropriate for your directory structure' ); } // Redirect output to a client’s web browser (PDF) header('Content-Type: application/pdf'); header('Content-Disposition: attachment;filename="pdf.pdf"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF'); // $objPHPExcel is set before this whole code block $objWriter->save('php://output');

instanceID