我正在使用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. 与parse.com Phonegap推送通知
- 3. Phonegap Build推送通知
- 4. Android推送通知Phonegap HTML5
- 5. Android的Phonegap推送通知
- 6. PhoneGap Meteor iOS推送通知
- 7. Phonegap推送通知实施
- 8. 在Android和Phonegap中推送通知
- 9. Phonegap IOS的Phonegap推送通知 - 推荐的解决方案
- 10. Phonegap推送通知是否可能?
- 11. Pushwoosh和Phonegap推送通知格式
- 12. Phonegap和Parse.com推送通知android
- 13. 使用phonegap + jQuery mobile推送通知
- 14. 未收到Phonegap iOS推送通知
- 15. Phonegap推送通知获取设备ID
- 16. Phonegap推送通知android,需要意见
- 17. Phonegap/Pushwoosh/Android - 推送通知不工作
- 18. PhoneGap支持的推送通知(家徽)?
- 19. Phonegap iOS推送通知示例
- 20. Phonegap Build推送通知插件问题
- 21. iPhone推送通知urbanairship,phonegap,c#
- 22. 在Asp.net中推送通知
- 23. 在ios中推送通知
- 24. 在php中推送通知
- 25. 推送推送通知
- 26. Cordova/PhoneGap推送通知与使用套接字通知
- 27. 推送通知
- 28. 推送通知
- 29. 推送通知
- 30. 推送通知
你有什么迄今所做?请在这里发布你的代码。 –
我安装了下面的插件 –
在这里发布你的错误,你得到了什么错误? –