【发布时间】:2018-11-10 02:15:21
【问题描述】:
我在我的应用中实现了 Ti.goosh 模块,用于从 Firebase 发送推送通知。我关注了this git document,并在 Google Developer Console API 中创建了一个新项目。我从那里获得了一个项目编号,并将其用作 tiapp.xml 中的“GCM 发件人 ID”。然后我在 index.js 控制器中添加了以下代码。
var TiGoosh = require('ti.goosh');
TiGoosh.registerForPushNotifications({
// The callback to invoke when a notification arrives.
callback: function(e) {
var data = JSON.parse(e.data || '');
},
// The callback invoked when you have the device token.
success: function(e) {
// Send the e.deviceToken variable to your PUSH server
Ti.API.log('Notifications: device token is ' + e.deviceToken);
},
// The callback invoked on some errors.
error: function(err) {
Ti.API.error('Notifications: Retrieve device token failed', err);
}
});
当我运行应用程序时,成功块执行并且我得到了设备令牌。但我没有收到来自 firebase 的消息。我也无法理解 Firebase 中的服务器密钥和 API 密钥应该包含在此模块中的哪个位置以与我的应用程序链接。
我怎样才能理解整个事情? Titanium 中的推送通知似乎非常复杂,文档也很差。
【问题讨论】:
-
查看firebase模块github.com/hansemannn/titanium-firebase
-
已实施,但在我这边不起作用。无法在我的应用中收到来自 firebase 的任何通知
标签: android firebase module push-notification titanium