android - 在 Titanium 中实现 Ti.goosh 推送通知模块以支持 Firebase
问题描述
我在我的应用程序中实现了 Ti.goosh 模块,用于从 Firebase 发送推送通知。我按照这个 git 文档在 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 中的推送通知似乎非常复杂,文档也很差。
解决方案
使用此 php 脚本发送通知并确认您收到带有 ti.goosh 的数据
您需要在脚本中包含您的 api 密钥和设备令牌 (registration_ids)
推荐阅读
- php - 它有时会使用 HLS 播放视频。例如,它播放 3 小时。10小时不播放视频
- javascript - 根据条件自动打开模态
- sql - 如何使用 CASCADE DELETE 删除所有租户数据
- python - Python:从排序数组中采样 n 个数字,确保它们彼此尽可能远
- active-directory - 我可以在 LDAP/radius/Tacas/Active Directory 中自定义身份验证吗
- xml - XSL FO 的两列布局流程
- arrays - Modelsim VHDL 数组初始化给出警告 (vcom-1320)
- python - 无法解决 ValueError: 层序贯_1 的输入 0 与层不兼容
- c# - 如何使用 Xamarin 表单创建功能发现
- c# - 在 Unity 3D 中,是否有理解何时引用变量以及何时将其复制到新变量的一般规则?