Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Titanium with how to run some code when user click on the notification? (Android)

$
0
0

how to run some code when user click on the notification? if user click push notification i want understand coming from push notification.

How can i do?

Thanks -Gcm Module- //my gcm module

var gcm = require("nl.vanvianen.android.gcm");
var lastData = gcm.getLastData();
    if (lastData) {
        Ti.API.info("Last notification received " + JSON.stringify(lastData));
        gcm.clearLastData();
    }
 
    gcm.registerPush({
 
        senderId : 'xxxxxxxx',
        notificationSettings : {
            sound : 'mysound.mp3',
            smallIcon : 'notification_icon.png',
            largeIcon : 'appicon.png',
            vibrate : true
        },
       //Push registration success
        success : function(event) {
            Ti.API.info("Push registration success: " + JSON.stringify(event));
 
        },
//Push registration error
        error : function(event) {
            Ti.API.info("Push registration error = " + JSON.stringify(event));
            alert(event.error);
        },
        //i want this function Coming from push
        data : function(event) {
 
            // console.log(" ******* Coming from push : " + JSON.stringify(event));
 
 
        },
       //my callback funtion call device token
        callback : function(event) {
            Ti.API.info("Push callback = " + JSON.stringify(event));
 
            var dialog = Ti.UI.createAlertDialog({
                title : 'Push received',
                message : JSON.stringify(event.data)
 
                // buttonNames: ['View'],
                // cancel: 1
 
            });
            dialog.addEventListener("click", function(event) {
                dialog.hide();
                if (event.index == 0) {
                    /* Do stuff to view the notification */
                }
            });
            dialog.show();
        },
    });

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>