我正在使用Phonegap創建移動應用程序。我想使用FCM創建推送通知。我使用了cordova-plugin-firebase插件。但它顯示錯誤。確實卡在項目中在Phonegap中推送通知?
0
A
回答
0
1)安裝插件(你已經這樣做)
cordova plugin add [email protected] --save
2)從你的火力帳戶下載兩個文件並保持文件的根文件夾:
google-services.json
GoogleService-Info.plist
3)在onDeviceReady寫這樣的代碼()方法:
onDeviceReady: function() {
window.FirebasePlugin.onTokenRefresh(function(token) {
//save this server-side and use it to push notifications to this device
console.log(token);
}, function(error) {
console.error(error);
});
}
這裏完整index.js代碼:
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
window.FirebasePlugin.onTokenRefresh(function(token) {
//save this server-side and use it to push notifications to this device
console.log(token);
}, function(error) {
console.error(error);
});
},
};
+0
已添加這些外部文件 –
+0
是否需要在index.html文件中添加外部文件鏈接? –
+0
我沒有添加GoogleService-Info.plist文件,我只想用於Android.So GoogleService-Info.plist文件是強制性的? –
相關問題
- 1. Phonegap推送通知實施
- 2. Android的Phonegap推送通知
- 3. 未收到Phonegap iOS推送通知
- 4. Phonegap推送通知獲取設備ID
- 5. Phonegap iOS推送通知示例
- 6. iPhone推送通知urbanairship,phonegap,c#
- 7. 在Asp.net中推送通知
- 8. 在php中推送通知
- 9. 推送推送通知
- 10. 如何使用FCM在phonegap中獲取推送通知值?
- 11. 在Phonegap Android App中本地存儲推送通知消息
- 12. 推送通知
- 13. 推送通知
- 14. 推送通知
- 15. 推送通知
- 16. 推送通知
- 17. 從推送通知中推送視圖
- 18. 在推送通知中發送URL Firebase
- 19. 在DevExtreme/Phonegap上使用FCM推送通知
- 20. 的推送通知添加新的圖標,在PhoneGap的
- 21. Phonegap推送通知顯示Xcode中的錯誤
- 22. 推送通知。在AndroidManifest.xml
- 23. 推送通知在PHP
- 24. ASP.NET中的推送通知
- 25. IOS8中的推送通知
- 26. Slient推送通知iOS中
- 27. Firebase推送通知
- 28. Devextreme推送通知
- 29. 推送通知?Iphone
- 30. 推送通知iPhone
你有什麼迄今所做?請在這裏發佈你的代碼。 –
我安裝了下面的插件 –
在這裏發佈你的錯誤,你得到了什麼錯誤? –