var gcm = require("nl.vanvianen.android.gcm");
/* If the app is started or resumed act on pending data saved when the notification was received */
var lastData = gcm.getLastData();
if (lastData) {
Ti.API.info("Last notification received " + JSON.stringify(lastData));
gcm.clearLastData();
}
gcm.registerPush({
senderId : 'XXXXXXXX',
notificationSettings : {
sound : '', /* Place sound file in platform/android/res/raw/mysound.mp3 */
smallIcon : 'appicon.png', /* Place icon in platform/android/res/drawable/notification_icon.png */
largeIcon : 'appicon.png', /* Same */
vibrate : true, /* Whether the phone should vibrate */
insistent : true, /* Whether the notification should be insistent */
group : 'MyNotificationGroup', /* Name of group to group similar notifications together */
localOnly : false, /* Whether this notification should be bridged to other devices */
priority : +2, /* Notification priority, from -2 to +2 */
bigText : true,
/* You can also set a static value for title, message, or ticker. If you set a value here, the key will be ignored. */
// title: '',
// message: '',
// ticker: ''
/* Add LED flashing */
ledOn : 200,
ledOff : 300
},
success : function(event) {
Ti.API.info("Push registration success: " + JSON.stringify(event));
synchronize(event);
},
error : function(event) {
Ti.API.error("Push registration error: " + JSON.stringify(event));
alert("Fail to register for remote push notification");
},
callback : function(event) {
Ti.API.info("Push callback = " + JSON.stringify(event));
// Called when a notification is received and the app is in the foreground
//TODO print message notification
var dialog = Ti.UI.createAlertDialog({
title : 'Push received',
message : JSON.stringify(event.data),
buttonNames : ['View', 'Cancel'],
cancel : 1
});
dialog.addEventListener("click", function(event) {
dialog.hide();
if (event.index == 0) {
//Do stuff to view the notification
}
});
dialog.show();
}
});
[INFO] : Push registration success: {"registrationId":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX8ny0B0KQa9UrCn8s","success":true}
[ERROR] : GCMIntentService: (IntentService[GCMIntentService--2]) [197,4105] Error: INVALID_SENDER
[ERROR] : GCMModule: (IntentService[GCMIntentService--2]) [1,4106] INVALID_SENDER
hello,
im using SDK 5.4.0 GA and 1.7 version of the module
this is my code
and i got a success registration and just after an error message
and just after
something missing? im sure that im calling this library one time !