var {google} = require('googleapis');
var MESSAGING_SCOPE = 'https://www.googleapis.com/auth/firebase.messaging';
var SCOPES = [MESSAGING_SCOPE];
function getAccessToken() {
return new Promise(function(resolve, reject) {
var key = require('./service-account.json');
var jwtClient = new google.auth.JWT(
key.client_email,
null,
key.private_key,
SCOPES,
null
);
}
}
字符串 1.输入请求URL为https://fcm.googleapis.com/v1/projects/<your-project-id>/messages:send,带有标题'Authorization': 'Bearer ' + accesstoken 使用POSTMAN Body > raw > JSON (application/json)进行设置并添加以下代码:
{
"message": {
"token": "FCM_TOKEN",
"data": {
"body": "Body of Your Notification in data",
"title": "Title of Your Notification in data",
"key_1": "Value for key_1",
"key_2": "Value for key_2"
}
}
}
1条答案
按热度按时间qnakjoqk1#
您可以使用POST请求来执行此操作,但需要首先使用服务凭据进行身份验证。最简单的方法是使用具有以下内容的节点应用程序:
字符串
1.输入请求URL为
https://fcm.googleapis.com/v1/projects/<your-project-id>/messages:send
,带有标题'Authorization': 'Bearer ' + accesstoken
使用POSTMAN
Body > raw > JSON (application/json)
进行设置并添加以下代码:型
但是,如果你想跳过所有的麻烦:Firebase有一个内置的FCM工具,允许你发送手动通知HERE