FCM推送通知在iOS上不起作用

时间:2019-02-25 15:21:55

标签: javascript ios firebase firebase-cloud-messaging firebase-admin

在admin.js中初始化Firebase:

import * as admin from "firebase-admin";

import serviceAccount from "./serviceAccount";

const options = {
  databaseURL: process.env.FIREBASE_DATABASE_URL,
  messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
  credential: admin.credential.cert(serviceAccount)
};

admin.initializeApp(options);

export default admin;

使用admin.js推送通知服务:

import Firebase from './admin';

const response = await Firebase.messaging().sendToDevice(
  notifications.registrationTokens, // tokens for android and iOS devices
  notifications.payload // formatted as: notification: { title: '', body: ''}
);

目前有两个错误:

1)iOS推送通知未显示

2)当应用在后台运行时,推送通知会两次发送到android设备。

0 个答案:

没有答案