Bar*_*n23 4 node.js firebase firebase-cloud-messaging
我正在遵循文档中的示例,但对注册令牌感到困惑。我正在本地本地服务器上测试推送通知。如何准确检索当前注册令牌,以及如何为多个Web应用程序用户生成注册令牌?
在文档中说:
Run Code Online (Sandbox Code Playgroud)// This registration token comes from the client FCM SDKs. var registrationToken = 'YOUR_REGISTRATION_TOKEN';`
获取用户令牌:
messaging.getToken().then(function(currentToken) {
if (currentToken) {
sendTokenToServer(currentToken);
updateUIForPushEnabled(currentToken);
} else {
// Show permission request.
console.log('No Instance ID token available. Request permission to generate one.');
// Show permission UI.
updateUIForPushPermissionRequired();
setTokenSentToServer(false);
}
}).catch(function(err) {
console.log('An error occurred while retrieving token. ', err);
showToken('Error retrieving Instance ID token. ', err);
setTokenSentToServer(false);
});
}
Run Code Online (Sandbox Code Playgroud)
更多信息在这里
然后将令牌添加到数据库并在Admin SDK中检索它
此处的更多信息:在Admin SDK中检索数据
| 归档时间: |
|
| 查看次数: |
3169 次 |
| 最近记录: |