IOS中的FCM错误:调用者没有权限?

时间:2019-01-30 06:25:31

标签: firebase react-native push-notification apple-push-notifications firebase-cloud-messaging

我正在使用Firebase节点Admin API将推送通知发送到Android和IO设备。 Android运行正常,但是在IOS中,我可以生成FCM令牌,但是当我从节点js(firebase管理代码)向IOS令牌发送推送通知时,出现以下错误:

 Error sending message: { Error: The caller does not have permission
    at FirebaseMessagingError.FirebaseError [as constructor] (/Users/MAC/Documents/Workspace/Nodejs/msever/Mserver/node_modules/firebase-admin/lib/utils/error.js:39:28)
    at FirebaseMessagingError.PrefixedFirebaseError [as constructor] (/Users/MAC/Documents/Workspace/Nodejs/msever/Mserver/node_modules/firebase-admin/lib/utils/error.js:85:28)
    at new FirebaseMessagingError (/Users/MAC/Documents/Workspace/Nodejs/msever/Mserver/node_modules/firebase-admin/lib/utils/error.js:250:16)
    at Function.FirebaseMessagingError.fromServerError (/Users/MAC/Documents/Workspace/Nodejs/msever/Mserver/node_modules/firebase-admin/lib/utils/error.js:280:16)
    at FirebaseMessagingRequestHandler.handleHttpError (/Users/MAC/Documents/Workspace/Nodejs/msever/Mserver/node_modules/firebase-admin/lib/messaging/messaging-api-request.js:125:50)
    at /Users/MAC/Documents/Workspace/Nodejs/msever/Mserver/node_modules/firebase-admin/lib/messaging/messaging-api-request.js:113:23
    at process._tickCallback (internal/process/next_tick.js:68:7)
  errorInfo:
   { code: 'messaging/mismatched-credential',
     message: 'The caller does not have permission' },
  codePrefix: 'messaging' }

我正在使用适用于Android和IOS的react native

2 个答案:

答案 0 :(得分:3)

根据您的错误信息

  

代码:“消息/不匹配的凭据”

Firebase official documentation说:

用于验证此SDK的凭据无权将消息发送到与提供的注册令牌相对应的设备。确保凭据和注册令牌都属于同一个Firebase项目。有关如何对Admin SDK进行身份验证的文档,请参见Add Firebase to your app

您可能正确配置了Android,但是错过了iOS的一些小功能。按照this link设置iOS客户端:)

答案 1 :(得分:0)

根据我的判断,推送通知在android上有效,但iOS由于某种原因给了我同样的错误。

我所做的是:

    从Firebase控制台
  1. 重新下载copy items if needed,以确保它是适用于iOS设备的版本
  2. 删除了项目中的旧版本
  3. 添加新选项,确保已选中import ogr,os from PyQt4.QtGui import * from PyQt4.QtCore import * from qgis.core import * import qgis.utils import glob import processing from processing.core.Processing import Processing from PyQt4.QtCore import QTimer Processing.initialize() Processing.updateAlgsList() #Add array of address below allFiles = ["C:/Shapefiles/Map_0077421.shp"] filesLen = len(allFiles) TexLayer = "C:/Texas_NAD27/Texas_NAD27.shp" for lop in range(filesLen): wb = QgsVectorLayer(allFiles[lop], 'tempshpfile', 'ogr') wbTex = QgsVectorLayer(TexLayer, 'TexasGrid', 'ogr') QgsMapLayerRegistry.instance().addMapLayer(wb) QgsMapLayerRegistry.instance().addMapLayer(wbTex) 选项
  4. 测试您是否通过控制台或admin sdk功能接收到推送通知