没有 cloudpush 的 android 的 getDeviceToken
getDeviceToken of android without cloudpush
我正在 Android 上集成推送通知。
根据 appcelerator article。
// notification setting
var deviceToken = null;
// Require the module
var CloudPush = require('ti.cloudpush');
// Initialize the module
CloudPush.retrieveDeviceToken({
success: deviceTokenSuccess,
error: deviceTokenError
});
// Enable push notifications for this device
// Save the device token for subsequent API calls
function deviceTokenSuccess(e) {
Ti.API.info("deviceTokenSuccess :" + e.deviceToken);
deviceToken = e.deviceToken;
}
function deviceTokenError(e) {
alert('Failed to register for push notifications! ' + e.error);
}
// Process incoming push notifications
CloudPush.addEventListener('callback', function (evt) {
alert("Notification received: " + evt.payload);
});
我需要获取 deviceToken 以将通知推送到 android,但此脚本使用 CloudPush,需要 'titanium Arrow service' 登录。
但是我想使用亚马逊 SNS 服务而不是 'Arrow service' 来推送消息,并且不想使用 Arrow 服务。
(我已经在iOS完成了亚马逊SNS的设置并且推送成功)
如何在不使用 cloudpush 的情况下获取 android deviceToken。
可以吗??
您可以使用https://github.com/morinel/gcmpush获取设备令牌
我正在 Android 上集成推送通知。
根据 appcelerator article。
// notification setting
var deviceToken = null;
// Require the module
var CloudPush = require('ti.cloudpush');
// Initialize the module
CloudPush.retrieveDeviceToken({
success: deviceTokenSuccess,
error: deviceTokenError
});
// Enable push notifications for this device
// Save the device token for subsequent API calls
function deviceTokenSuccess(e) {
Ti.API.info("deviceTokenSuccess :" + e.deviceToken);
deviceToken = e.deviceToken;
}
function deviceTokenError(e) {
alert('Failed to register for push notifications! ' + e.error);
}
// Process incoming push notifications
CloudPush.addEventListener('callback', function (evt) {
alert("Notification received: " + evt.payload);
});
我需要获取 deviceToken 以将通知推送到 android,但此脚本使用 CloudPush,需要 'titanium Arrow service' 登录。
但是我想使用亚马逊 SNS 服务而不是 'Arrow service' 来推送消息,并且不想使用 Arrow 服务。
(我已经在iOS完成了亚马逊SNS的设置并且推送成功)
如何在不使用 cloudpush 的情况下获取 android deviceToken。
可以吗??
您可以使用https://github.com/morinel/gcmpush获取设备令牌