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

subscribed to push notifications, but send status fail and message status unknown.

$
0
0

Hi

I put retrieveDeviceToken and addEventListener with CloudPush on alloy.js

var CloudPush = require('ti.cloudpush');
 
// Initialize the module
CloudPush.retrieveDeviceToken({
    success: deviceTokenSuccess,
    error: deviceTokenError
});
 
// Enable push notifications for this device
// Save the device token for subsequent API calls
function deviceTokenSuccess(e) {
    Alloy.Globals.deviceToken = e.deviceToken;
}
 
function deviceTokenError(e) {
    alert('Failed to register for push notifications! ' + e.error);
}
 
CloudPush.debug = true;
//CloudPush.showTrayNotification = true; 
//CloudPush.showAppOnTrayClick = true; 
 
// Process incoming push notifications
CloudPush.addEventListener('callback', function (evt) {
    alert("Notification received: " + evt.payload);
});
Then setting subscribe and unsubscribe on index.js
// Require the Cloud module
var Cloud = require("ti.cloud");
Cloud.debug = true;
 
function subscribeToChannel() {
    Cloud.PushNotifications.subscribeToken({
        device_token: Alloy.Globals.deviceToken,
        channel: 'NecombArrpove',
        type: Ti.Platform.name == 'android' ? 'android' : 'ios'
    }, function (e) {
        if (e.success) {
            alert('Subscribed');
        } else {
            alert('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
        }
    });
}
 
function unsubscribeToChannel() {
    Cloud.PushNotifications.unsubscribeToken({
        device_token: Alloy.Globals.deviceToken,
        channel: 'NecombArrpove',
    }, function (e) {
        if (e.success) {
            alert('Unsubscribed');
        } else {
            alert('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
        }
    });
}
 
function subscribe(e) {
    subscribeToChannel();
}
 
function unsubscribe(e) {
    unsubscribeToChannel();
}
 
$.index.open();
My app can subscribed to push notifications. But when sending message, the app can't receive. In show push logs are send status fail and message status unknown.

Please help.


Viewing all articles
Browse latest Browse all 8068

Trending Articles



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