liccowee/Google-Cloud-Messaging--Titanium-

Notification

Closed this issue · 4 comments

I receive notification push when app is in background.

The first problem is i dont want to see red icon but the icon of the app in notification list.
here the code concerned :
2130837504

what should i do to display app's icon (/images/icon.png) for example or the default icon.

Second think,

when i click in message in notification list, it doesn't open the app but delete the message in notifications list.

any suggestions ?

thanks

any new for this ?

thanks for help

did you find a solution for this? I'm having the exact same problem, when user clicks on the notification (inside the notification tray) the notification gets deleted and the app will NOT open.

Hi there, i solve this problem by using this method :
when push is received the data is stored in Ti.App.Properties.hasProperty("com.activate.gcm.last_data")
then i clear all the push notification created by gcm module using : Ti.Android.NotificationManager.cancelAll();
and i create my own notification using titanium

when i click on the notification the app is opened and i check is the property exist then is clear clear the property and i parse my data.

.
.
.
callback:function(e) // called when a push notification is received
{
                //Ti.API.info('JS message event: ' + JSON.stringify(e.data));
                //alert('JS message event: ' + JSON.stringify(e.data));
                //var data = e.data;

                //same as e.data
                var data = Ti.App.Properties.getString("com.activate.gcm.last_data","");
                data = JSON.parse(data);
                //Ti.App.Properties.removeProperty("com.activate.gcm.last_data");
                //Ti.App.Properties.hasProperty("com.activate.gcm.last_data");
                Ti.Android.NotificationManager.cancelAll();

                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,
                    packageName:'com.mutationevent.demoapp',
                    className:'com.mutationevent.cityguidemarrakech.DemoappActivity',
                });

                // This is fairly static: Not much need to be altered here
                var pending = Ti.Android.createPendingIntent({
                    activity:Ti.Android.currentActivity,
                    intent:intent,
                    type:Ti.Android.PENDING_INTENT_FOR_ACTIVITY
                });

                var notification = Ti.Android.createNotification
                ({
                        icon:Ti.App.Android.R.drawable.appicon,
                        contentIntent:pending,
                        contentTitle:e.data.title,
                        contentText:e.data.message,
                        //tickerText:'New Message'
                        //sound:Ti.Android.NotificationManager.DEFAULT_SOUND,
                        defaults:Ti.Android.NotificationManager.DEFAULT_ALL,
                });
                Ti.Android.NotificationManager.notify(1, notification);

                //do what you wan here


            }

and in the app.js

check is the property exist (when the app is opened)

if(Ti.App.Properties.hasProperty("com.activate.gcm.last_data")){
// do what you want here
}

+1 mutationevent for this (i'll try if it works)