Hi, I am working android pushnotification, my device is registered in ACS but push is coming to my device
if(Ti.Platform.osname == 'android')
{
var CloudPush = require('ti.cloudpush');
CloudPush.debug = true;
// CloudPush.enabled = true;
CloudPush.showTrayNotificationsWhenFocused = true;
//CloudPush.focusAppOnPush = false;
var deviceToken;
try{
CloudPush.retrieveDeviceToken({
success: function deviceTokenSuccess(e) {
deviceToken = e.deviceToken;
alert('deviceToken! ' + deviceToken);
Ti.API.info('deviceToken::@@@@: '+deviceToken);
registerForAndroid();
//unSubCribeAndroidPush(deviceToken);
},
error: function deviceTokenError(e) {
alert('Failed to register for push! ' + e.error);
}
});
}
catch(e)
{
alert('Error '+e.error);
}
function registerForAndroid(){
//alert('register');
Cloud.PushNotifications.subscribe({
channel: 'friend_request', //'alert' is channel name
device_token: deviceToken,
type: 'gcm' //here i am using gcm, it is recommended one
}, function (e) {
if (e.success) {
CloudPush.setEnabled(true);
setAndroiPushEnable();
alert('Subscribed for Push Notification!');
} else {
alert('Subscribe error:'+e.message );
}
});
}
↧