I Receive an error every time when i run this code relating to push notification Error : Missing fields.Required: device_Token and channel
var Cloud=require('ti.cloud'); var CloudPush=require('ti.cloudpush');
var deviceToken=""; CloudPush.retrieveDeviceToken({ success: function deviceTokenSuccess(e) { alert('Device Token: ' + e.deviceToken); deviceToken = e.deviceToken; }, error: function deviceTokenError(e) { alert('Failed to register for push! ' + e.error); } }); //3)Cloud User Login Cloud.Users.login({ login: 'test@mycompany.com', password: 'test_password'
}, function (e) { if (e.success) { alert("login success"); subsribe(); } else { alert('Error: ' +((e.error && e.message) || JSON.stringify(e))); } }); //4)Subscribe a Channel
function subscribe(){ Cloud.PushNotifications.subscribe({ channel: 'alert', // "alert" is channel name device_token: deviceToken, type: 'android' }, function (e){ if (e.success) { alert('Subscribed for Push Notification!'); }else{ alert('Error:' +((e.error && e.message) || JSON.stringify(e))); } });
}