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

Titanium ACS shows 1 subscriber for android not receiving GCM notification on device

$
0
0

i am trying to work on GCM and ACS to send Notifications

i have successfully done all the work related to google GCM api key , sender id adding the required oauth and api keys for both production and development , i have two problems

1) the Development console of ACS shows 1 Android client subscribed to push notifications. however there is no such thing shown in Production Console, it still shows 0 Android clients subscribed to push notifications.

2) I Have verified the Device Token with the one shown on device and the one registered with ACS , they both are SAME , however I AM NOT RECEIVING NOTIFICATIONS ON DEVICE

3) i have

CloudPush.debug = true;
CloudPush.enabled = true;
CloudPush.showTrayNotificationsWhenFocused = true;
CloudPush.focusAppOnPush = false;
other Details

Titanium Studio, build: 3.1.3.201309132423 sdk-version 3.1.3.GA Android

ti.cloudpush 2.3.3

I HAVE NO ROOT firewall Installed, tried disabling it Still no success,

even tried disabling debug mode and no success.

this is the code i am trying

Titanium.UI.setBackgroundColor('#000');
var deviceToken;
var win = Ti.UI.createWindow({
    backgroundColor : '#ccc',
    title : 'Android Cloud Push Notification'
});
alert('Device_token Called');
var CloudPush = require('ti.cloudpush');
 
//fetch device token
CloudPush.retrieveDeviceToken({
    success : function deviceTokenSuccess(e) {
        deviceToken = e.deviceToken;
        alert('Device Token: ' + deviceToken);
        Ti.API.info('Device Token: ' + e.deviceToken);
    },
    error : function deviceTokenError(e) {
        alert('Failed to register for push! ' + e.error);
    }
});
alert('Device_token completed'); 
CloudPush.debug = true;
CloudPush.enabled = true;
CloudPush.showTrayNotificationsWhenFocused = true;
CloudPush.focusAppOnPush = false;
 
var Cloud = require('ti.cloud');
Cloud.debug = true;
 
var submit = Ti.UI.createButton({
    title : 'Register For Push Notification',
    color : '#000',
    height : '53dp',
    width : '200dp',
    top : '100dp'
});
 
win.add(submit);
 
submit.addEventListener('click', function(e) {
    loginDefault();
});
 
function loginDefault(e) {
    //Create a Default User in Cloud Console, and login with same credential
    Cloud.Users.login({
        login : 'push123',
        password : 'push123'
    }, function(e) {
        if (e.success) {
            alert("Login success");
            defaultSubscribe();
        } else {
            alert('Login error: ' + ((e.error && e.message) || JSON.stringify(e)));
        }
    });
}
alert('Subscribe Started');
function defaultSubscribe() {
    Cloud.PushNotifications.subscribe({
        channel : 'alert2',//'alert' is channel name
        device_token : deviceToken,
        //type : 'android' //here i am using gcm, it is recomended one
        type : 'gcm'
    }, function(e) {
        if (e.success) {
            alert('Subscribed for Push Notification!');
        } else {
            alert('Subscrib error:' + ((e.error && e.message) || JSON.stringify(e)));
        }
    });
}
alert('Subscribe Ended');
 
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)');
});
win.open();
i just want to receive notifications on Android device , i have even tried disabling debug mode, ANy help would be great

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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