我正在使用与 firebase react-native来使用 fcm 推送通知..
这是文档网络示例
// Node.js
var admin = require('firebase-admin');
// ownerId - who owns the picture someone liked
// userId - id of the user who liked the picture
// picture - metadata about the picture
async function onUserPictureLiked(ownerId, userId, picture) {
// Get the owners details
const owner = admin
.firestore()
.collection('users')
.doc(ownerId)
.get();
// Get the users details
const user = admin
.firestore()
.collection('users')
.doc(userId)
.get();
await admin.messaging().sendToDevice(
owner.tokens, // ['token_1', 'token_2', ...]
{
data: {
owner: JSON.stringify(owner),
user: JSON.stringify(user),
picture: JSON.stringify(picture),
},
},
{
// Required for background/quit data-only messages on iOS
contentAvailable: true,
// Required for background/quit data-only messages on Android
priority: 'high',
},
);
}
文档说我是否想通过使用 rest api 而不是 firebase admin 来请求消息
我必须使用这个网址
这是
https://fcm.googleapis.com/fcm/send
但我很困惑我该如何使用这个网址??
我想知道我应该在后端还是前端使用这个网址?