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

CloudPush 3.3.4 not firing PUSH callback?

$
0
0

Hi Guys. Having some issues with CloudPush 3.3.4

// SETUP CLOUDPUSH
    CloudPush.debug = true;
// CloudPush.enabled = true;
    CloudPush.showTrayNotificationsWhenFocused = false;
    CloudPush.focusAppOnPush = false;
// REGISTER AND GET DEVICE TOKEN
    CloudPush.retrieveDeviceToken({
        success: deviceTokenSuccess,
        error: deviceTokenError
    });
 
    CloudPush.addEventListener('callback', function (evt) {
        var data = JSON.parse(evt.payload);
        Ti.API.warn('[PUSH] CALL BACK ALERT:'+data.android.alert);
        var pushAlert = Titanium.UI.createAlertDialog({
            title:data.android.title, 
            message:data.android.alert
        });
        pushAlert.show();
    });
 
    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)');
    });
 
    // Save the device token for subsequent API calls
    function deviceTokenSuccess(e) {
        Ti.API.info('Device Token: ' + e.deviceToken);
        Alloy.Globals.devicetoken = e.deviceToken;
        // Register with Cloud API for PUSH
        Cloud.PushNotifications.subscribe({
            channel: 'all',
            device_token: e.deviceToken,
            type: 'android'
        }, function (f) {
            if (f.success) {
                // alert('Device ID:'+e.deviceToken);
            } else {
                alert('push Error:\n' +
                    ((f.error && f.message) || JSON.stringify(f)));
            }
        });
    }
 
    function deviceTokenError(e) {
        alert('Failed to register for push notifications! ' + e.error);
    }
When the app is running, i see the PUSH alert arrive in the console but the callback isn't triggered.
[INFO] :   APSCloudPush: receivePayload: {"android":{"title":"THIS IS A TEST","sound":"default","alert":"uygkhjgj","vibrate":true,"badge":1}}
[INFO] :   APSCloudPush: background: true
[INFO] :   APSCloudPush: processCallbackIfInstantiated payload: {"android":{"title":"THIS IS A TEST","sound":"default","alert":"testing","vibrate":true,"badge":1}}
Any ideas where I'm going wrong?

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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