I have succesfully included a C2DM Module (Android's Cloud to Device Messaging Framework) in my project and have been able to succesfully register and receive Android push notifications. However, I have noticed that every once in a while, when I send the notifications the new Notification is not displayed on the device. Today, I plugged in my device and used the adb logcat and noticed that the IntentService[c2dmBaseReceiver] was actually being fired and it received the message I sent, however the callback function was not being because the V8 Runtime had been disposed (see following lines from logcat)
D/C2DMReceiver( 1069): (IntentService[C2DMBaseReceiver]) [369956,441456] Message received
D/C2DMReceiver( 1069): (IntentService[C2DMBaseReceiver]) [1,441457] Message key: message value: This is a test notification
D/C2DMReceiver( 1069): (IntentService[C2DMBaseReceiver]) [0,441457] Message key: title value: myAppName
D/C2DMReceiver( 1069): (IntentService[C2DMBaseReceiver]) [2,441459] Message key: tickerText value: Notification Ticker
D/C2DMReceiver( 1069): (IntentService[C2DMBaseReceiver]) [1,441460] Message key: from value: abrahamvivas@gmail.com
D/C2DMReceiver( 1069): (IntentService[C2DMBaseReceiver]) [0,441460] Message key: collapse_key value: myApp Alert
W/V8Function( 1069): Runtime disposed, cannot call function
This is my callback
callback:function(e)
{
Ti.API.info('JS message event: ' + JSON.stringify(e.data));
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_MAIN,
flags: Ti.Android.FLAG_ACTIVITY_NEW_TASK | Ti.Android.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
className: 'com.avivas.myApp.myAppActivity',
packageName: 'com.avivas.myApp'
});
intent.addCategory(Ti.Android.CATEGORY_LAUNCHER);
var pending = Ti.Android.createPendingIntent({
activity: Ti.Android.currentActivity,
intent: intent,
type: Ti.Android.PENDING_INTENT_FOR_ACTIVITY,
});
var notification = Ti.Android.createNotification({
contentIntent: pending,
contentTitle: e.data.title,
contentText: e.data.message,
tickerText: e.data.tickerText
});
Ti.Android.NotificationManager.notify(1, notification);
Titanium.Media.vibrate([0,300, 100, 300]);
}
I'm assuming that because the callback function from c2dm is in javascript, it can't execute because the V8 runtime has been disposed. Is there anyone who can confirm this? In addition, is there any workaround for this as I would like to display a notification when I receive one?