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

Titanium CloudPush Event Why does not work? (android)

$
0
0

i added push notification "events" but is not working.

I dont understand. Error can not be given and Log in is not working.

please help me. Thanks

var gcm = require("nl.vanvianen.android.gcm"); 
var CloudPush = require('ti.cloudpush');
 
var lastData = gcm.getLastData();
    if (lastData) {
        Ti.API.info("Last notification received " + JSON.stringify(lastData));
        gcm.clearLastData();
    }
 
    gcm.registerPush({
 
        senderId : '480608162759',
        notificationSettings : {
            sound : 'mysound.mp3',
            smallIcon : 'notification_icon.png',
            largeIcon : 'appicon.png',
            vibrate : true
        },
        success : function(event) {
            Ti.API.info("Push registration success: " + JSON.stringify(event));
 
        },
        error : function(event) {
            Ti.API.info("Push registration error = " + JSON.stringify(event));
            alert(event.error);
        },
 
        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();
        },
    });
       //Dont work eventlistener
    CloudPush.addEventListener('callback', function(evt) {
        console.log("Notification received: " + evt.payload);
    });

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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