最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - FCM Admin - where are the registration tokens for web app users? - Stack Overflow

programmeradmin0浏览0评论

I'm following the example on the documentations, but I'm confused about registration tokens. I'm testing the push notifications on my local express server. How exactly do I retrieve the current registration token, and how do I generate registration tokens for multiple web app users?

I'm following the example on the documentations, but I'm confused about registration tokens. I'm testing the push notifications on my local express server. How exactly do I retrieve the current registration token, and how do I generate registration tokens for multiple web app users?

Share Improve this question edited Dec 5, 2019 at 8:54 Peter Haddad 81k25 gold badges145 silver badges146 bronze badges asked Apr 18, 2018 at 6:12 Bargain23Bargain23 1,9734 gold badges32 silver badges58 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

In the docs it says:

// This registration token es from the client FCM SDKs.
var registrationToken = 'YOUR_REGISTRATION_TOKEN';`

To get the user's 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);
  });
}

more info here

Then add the token to the database and retrieve it in the Admin SDK

more info here: Retrieve data in Admin SDK

发布评论

评论列表(0)

  1. 暂无评论