【问题标题】:How to Titanium with handle push notification?Titanium如何处理推送通知?
【发布时间】:2015-11-13 22:02:07
【问题描述】:

我使用 caffeina GCM 和 Titanium。我想转换通知对象推送到 JSON 对象。我该怎么办?

我想要动态。

谢谢

var req = require('it.caffeina.gcm').registerForPushNotifications({

    senderId : '480608162759',

    success : function(e) {
        console.log(e.deviceToken);


    },
    error : function(err) {
        Ti.API.error('Notifications: Retrieve device token failed', err);
    }
});

【问题讨论】:

    标签: javascript android mobile titanium


    【解决方案1】:

    你是说这个吗?

    require('it.caffeina.gcm').registerForPushNotifications({
    
      senderId : 'YOUR_SENDER_ID',
    
      success : function(e) {
          console.log('deviceToken', e.deviceToken);
      },
      error : function(err) {
          console.error('Notifications: Retrieve device token failed', err);
      },
      callback: function(e) {
    
        var payload = null;
        try {
          // push payload is inside e.data
          payload = JSON.parse(e.data);
        } catch(ex) {
          console.error('error reading push payload', ex);
        }
    
        // if(payload) do whatever you want with payload ....
    
      }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-09
      • 2017-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多