在Titanium for Firebase支持中实施Ti.goosh推送通知模块

时间:2018-05-31 06:29:36

标签: android firebase module push-notification titanium

我已在我的应用中实施了Ti.goosh模块,用于从Firebase发送推送通知。我关注了this git文档,并在google开发者控制台API中创建了一个新项目。我从那里得到了一个项目编号,并将其用作#34; GCM发件人ID"在tiapp.xml中。然后我在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);
    }
});

当我运行app时,成功阻止执行并获得设备令牌。但是我没有从firebase那里得到消息。我也无法理解firebase中的服务器密钥和API密钥应该包含在这个模块中以与我的应用程序链接。任何人都可以帮助我理解整个事情吗?看起来,钛的推送通知非常复杂,文档很差。

1 个答案:

答案 0 :(得分:0)

使用this php script发送通知并确认您使用ti.goosh

接收数据

您需要在脚本中包含api密钥和设备令牌(registration_ids)