Error with the Push Notification

You must Login before you can answer or comment on any questions.

Hello everybody,

I am trying to test the push notification using Titanium, I followed this tuto word by word:

http://www.titaniumtutorial.com/2012/06/appcelerator-cloud-push-notification-in.html

app.js

Titanium.UI.setBackgroundColor('#000');
 
var win = Ti.UI.createWindow({
    backgroundColor:'#ccc',
    title:'Android Cloud Push Notification'
})
 
 
var CloudPush = require('ti.cloudpush');
        CloudPush.debug = true;
        CloudPush.enabled = true;
        CloudPush.showTrayNotificationsWhenFocused = true;
        CloudPush.focusAppOnPush = false;
 
var deviceToken;
var Cloud = require('ti.cloud');
    Cloud.debug = true;
 
 
var submit = Ti.UI.createButton({
    title : 'Register For Push Notification',
    color:'#000',
    height : 120,
    width : 220,
    top : 100,
});
 
win.add(submit);
 
submit.addEventListener('click', function(e) {
        CloudPush.retrieveDeviceToken({
                success: function deviceTokenSuccess(e) {
                    alert('Device Token: ' + e.deviceToken);
                    deviceToken = e.deviceToken
                    loginDefault();
                },
                error: function deviceTokenError(e) {
                    alert('Failed to register for push! ' + e.error);
                }
        });
});
 
 
function loginDefault(e){
    //Create a Default User in Cloud Console, and login
    Cloud.Users.login({
        login: '******',
        password: '******'
    }, function (e) {
        if (e.success) {
            alert("login success");
            defaultSubscribe();
        } else {
            alert('Error: ' +((e.error && e.message) || JSON.stringify(e)));
            }
        });
}
 
function defaultSubscribe(){
                Cloud.PushNotifications.subscribe({
                    channel: 'alert',
                    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)));
                    }
                });
}
 
CloudPush.addEventListener('callback', function (evt) {
    //alert(evt);
    //alert(evt.payload);
});
 
CloudPush.addEventListener('trayClickLaunchedApp', function (evt) {
    Ti.API.info('Tray Click Launched App (app was not running)');
    //alert('Tray Click Launched App (app was not running');
});
 
CloudPush.addEventListener('trayClickFocusedApp', function (evt) {
    Ti.API.info('Tray Click Focused App (app was already running)');
    //alert('Tray Click Focused App (app was already running)');
});
 
 
win.open();
But, when I tried to test the code (in the fifth element ( 5-Android Push Configuration) ) , normally, I must receive 3 alerts... Instead, I receive an error message
Error: Invalid email/username and password
In general, getting a devicetoken is no problem. Then I try to login to the cloud with a user. That gives no success. There is always the following error: Invalid email/username or password. I'm sure the username ande password is correct.

P.S: I am testing this code using an android Device, and using this specifications into my app:

Titanium sdk ver. : 2.1.0.GA Android runtime : V8 ti.cloudpush : 2.0.5 ti.cloud : 2.1.0

What's wrong with this?

Thank you in advance!

2 Answers

Accepted Answer

Plz make sure that u have made the user on development side and not on production side.

I don't if you can help me on this:

I was able to see (1) Android device added on the push notification screen.(same as a screen shot on the blog). Then I tried sending the Notification through the test form provided by appcelerator.

Problem is i never received the notification :(

I tried it twice, but no results !

Wat can be wrong in this ?

— answered 2 years ago by Karray Gargouri
answer permalink
13 Comments
  • Plz see whether the device is added on development side?

    — commented 2 years ago by Muhammad Wahhab Mirza

  • And send the push notification from development side

    — commented 2 years ago by Muhammad Wahhab Mirza

  • My device is added on the development side, and I send the push notification, also, from the development side but there is no notification received ! :(

    Any suggestions ?

    — commented 2 years ago by Karray Gargouri

  • Show 10 more comments

Your Answer

Think you can help? Login to answer this question!