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

Getting two Push notification iinstead of one

$
0
0

Hello all, I am trying to set up Push notifications for Android. I am followed guides and docs but I'm getting unexpected results, when I send a push notification the callback event is fired once but two notification are visible, one with the correct data and another in blank.

The code I'm using is copied from http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.CloudPush

var CloudPush = require('ti.cloudpush');
                    CloudPush.retrieveDeviceToken({
                        success: function deviceTokenSuccess(e) {
                            // Use this device token with Ti.Cloud.PushNotifications calls
                            // to subscribe and unsubscribe to push notification channels
                            Ti.API.info('Device Token: ' + e.deviceToken);
                        suscribirCanal(param1, e.deviceToken);
                        },
                        error: function deviceTokenError(e) {
                            alert('Failed to register for push! ' + e.error);
                        }
                    });
                    // These events monitor incoming push notifications
                    CloudPush.addEventListener('callback', function (evt) {
                        alert(evt.payload);
                    });
                    CloudPush.addEventListener('trayClickLaunchedApp', function (evt) {
                        Ti.API.info('Tray Click Launched App (app was not running)');
                    });
                    CloudPush.addEventListener('trayClickFocusedApp', function (evt) {
                        Ti.API.info('Tray Click Focused App (app was already running)');
                    });
and the suscribirCanal function is :
if(token !="-1"){
    var Cloud = require("ti.cloud");
 
    Cloud.PushNotifications.subscribeToken({
        device_token: token,
        channel:canal,
        type: Ti.Platform.name == 'android' ? 'android' : 'ios'
    }, function (e) {
        if (e.success) {
            funciones.error("Suscripcion al canal "+canal+" realizada correctamente"); 
                   } else {
            funciones.error('Error al realizar la suscripcion al canal '+canal+':\n' + ((e.error && e.message) || JSON.stringify(e)));
        }
    });
    }
I have tried configuring CloudPush attributes like showTrayNotification and singleCallback with no result.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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