Problem Description
The console tab in ACS shows a number for ios and android devices that are "Registered for Push Notifications" We have over 800 devices listed under the "Show Registered Devices" tab however it says there are 0 iOS devices and 0 Android devices.
We Tried With the Following Code and We found some issues in web-portal Push Notification Subscribed Devices. Sometimes it Sows the Devices, Other times only the Device got Detected but not listed in “Show Subscribed Devices” Section.
TestCase
Titanium.UI.setBackgroundColor('#000');
var win = Ti.UI.createWindow({
backgroundColor : '#ccc',
title : 'Android Cloud Push Notification'
});
var CloudPush = require('ti.cloudpush');
CloudPush.debug = true;
CloudPush.enabled = true;
CloudPush.showTrayNotificationsWhenFocused = true;
CloudPush.focusAppOnPush = false;
var deviceToken;
var Cloud = require('ti.cloud');
Cloud.debug = true;
var submit = Ti.UI.createButton({
title : 'Register For Push Notification',
color : '#000',
height : 53,
width : 200,
top : 100,
});
win.add(submit);
submit.addEventListener('click', function(e) {
CloudPush.retrieveDeviceToken({
success : function deviceTokenSuccess(e) {
alert('Device Token: ' + e.deviceToken);
deviceToken = e.deviceToken;
loginDefault();
},
error : function deviceTokenError(e) {
alert('Failed to register for push! ' + e.error);
}
});
});
function loginDefault(e) {
// At first you need to create an user from the application dashboard
// Then login that email and password
Cloud.Users.login({
login : 'user’,
password : 'pass'
}, function(e) {
if (e.success) {
alert("login success");
defaultSubscribe();
} else {
alert('Error: ' + ((e.error && e.message) || JSON.stringify(e)));
}
});
}
function defaultSubscribe() {
Cloud.PushNotifications.subscribe({
channel : 'alert',
device_token : deviceToken,
type : 'android'
}, function(e) {
if (e.success) {
alert('Subscribed for Push Notification!');
} else {
alert('Error:' + ((e.error && e.message) || JSON.stringify(e)));
}
});
}
CloudPush.addEventListener('callback', function(evt) {
//alert(evt);
//alert(evt.payload);
});
CloudPush.addEventListener('trayClickLaunchedApp', function(evt) {
Ti.API.info('Tray Click Launched App (app was not running)');
//alert('Tray Click Launched App (app was not running');
});
CloudPush.addEventListener('trayClickFocusedApp', function(evt) {
Ti.API.info('Tray Click Focused App (app was already running)');
//alert('Tray Click Focused App (app was already running)');
});
win.open();
Steps to reproduce
1. Create a new app with Cloud Service Enabled
2. Copy the Code provided to the new app
3. [Login](
https://my.appcelerator.com/apps/) ,you will see your new app is listed there.
4. Go to the [link](
https://console.developers.google.com) and create a Google API project and enable its GSM service. Follow the [link](
http://docs.appcelerator.com/platform/latest/#!/guide/Configuring_push_services) for Details.
5. Get the "Google Cloud Messaging (GCM)" API Key and "Google Cloud Messaging (GCM) Sender ID" and submit them in In the web-portal "Android Push Configuration section", of your app.
6. Create an user in your app with your login details in the web-portal.
7. Provide the login details in the "Code segment", “Cloud.Users.login” section.
8. Run the project in an android device.
9. Touch “Push Notification”, you will see the device is detected
Expected results
In web-portal, under the “Push Notification”, “Show Subscribed Devices” section the device should appear.
Actual Results
Sometimes the Device is detected by the app but it’s not listed in the web-portal under the “Push Notification”, “Show Subscribed Devices” section.
[~david.call@uvu.edu], I have cloned original ticket here. [~mpmiranda], Please update this ticket when get updates on internal one.