3

Im trying to use GCM with Titanium Studio, and I wanna be able to implement Push Notification in my Android App: Im using the code bellow:

var CloudPush = require('ti.cloudpush');
var deviceToken = null;


CloudPush.retrieveDeviceToken({
    success: deviceTokenSuccess,
    error: deviceTokenError
});

function deviceTokenSuccess(e) {
    CloudPush.enabled = true;
    deviceToken = e.deviceToken;
}

function deviceTokenError(e) {
    alert('Failed to register for push notifications! ' + e.error);
}

CloudPush.addEventListener('callback', function (evt) {
    alert(evt.payload);
});

CloudPush.addEventListener('trayClickLaunchedApp', function (evt) {
    Ti.API.info('Tray Click Launched App (app was not running)');
});


CloudPush.addEventListener('trayClickFocusedApp', function (evt) {
    Ti.API.info('Tray Click Focused App (app was already running)');
});

When I run the code I get error: Failed to register for push notifications! Failed receiving GCM SenderId, Getting GCM SenderId failed. Max retry time reaches.

What can I do to resolve this error I get?

Mr Toni WP
  • 191
  • 3
  • 15

1 Answers1

-1

There are many error in your code and also i think you are not setting the GCM sender Id.You have to follow this tutorial and i think you would be good to go

http://www.tidev.io/2013/12/20/using-gcm-for-android-push-notifications-with-acs/

Thanks

Wahhab_mirza
  • 1,484
  • 2
  • 10
  • 17
  • Hi, Ok Im gonna try to follow the tutorial. – Mr Toni WP Apr 01 '14 at 08:01
  • I get this error: 'Failed to get device token' + error: Failed to register for push notifications! Failed receiving GCM SenderId, Getting GCM SenderId failed. Max retry time reaches. Do I maybe have to add a SIM-card to my Galaxy Samsung 4? Could that be the problem? – Mr Toni WP Apr 01 '14 at 08:13
  • Nope you have to have only the wifi as far as i think – Wahhab_mirza Apr 01 '14 at 18:11
  • The article you posted contains the exact code as in the original post. This doesnt answer the question – Flame Jan 18 '17 at 13:13