![](/img/trans.png)
[英]Calling another JavaScript method in a class in a hybrid Cordova/Android app
[英]Google Cloud Message: get RegistrationId from Cordova hybrid app in JavaScript
我剛剛開始為Android開發應用程序。 我已經在telerik平台上完成了Hybrid Cordova應用程序,所以我使用javascript作為語言。 我需要獲取從服務器發送到我的android設備的推送通知。 我在Firebase中有一個項目,並且在代碼中設置了正確的google API密鑰和ProjectId。 為了從服務器發送消息,我需要我的應用程序的注冊ID。 我怎么能得到? 我在Java中找到了很多示例,但在javascript中卻找不到。 謝謝!
使用cordova push插件。您可以在此處查看參考鏈接 。
使用該插件,您可以像這樣獲得注冊ID:
var push = PushNotification.init({ "android": {"senderID": "YourSenderID"},
"ios": {"alert": "true", "badge": "true", "sound": "true"}, "windows": {} } );
push.on('registration', function(data) {
console.log(data.registrationId);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.