[TIMOB-25022] Android : CloudPush Callback didnt fire after open a new window in Alloy
GitHub Issue
n/a
Type
Bug
Priority
n/a
Status
Reopened
Resolution
Unresolved
Affected Version/s
Release 6.0.3
Fix Version/s
n/a
Components
n/a
Labels
android, engSchedule, pushnotification
Reporter
Yellowcube
Assignee
Unknown
Created
2017-03-28T02:35:28.000+0000
Updated
2019-10-17T07:10:03.000+0000
Description
The CloudPush Callback is not working after the app open a new window.
Ti.Cloud Modules Version : 3.2.11
Ti.Cloudpush Modules Version: 4.0.3
Ti.SDK Version : 6.0.3 GA
The CloudPush Callback only fired when i first launched the app and didn't open a new window whenever a new notifications come in.
That means it will not fire anymore if i open a second window and a new notification come in.
But, the callback will show the previous notification which didn't show in the second window after i kill the app and relaunch it.
Besides that, the CloudPush trayClickLaunchedApp and trayClickFocusedApp EventListener not working also.
There are some Warning showed in the console when i stayed in second window and receive a new notification come in as the screenshort attached.
Sample code of my project:
-----------------------------------------------------------------------------------------------------------------------------
alloy.js
var CloudPush = require('ti.cloudpush');
CloudPush.debug = true;
CloudPush.enabled = true;
CloudPush.showTrayNotificationsWhenFocused = true;
CloudPush.showTrayNotification = true;
CloudPush.focusAppOnPush = false;
var deviceToken = null;
var Cloud = require('ti.cloud');
Cloud.debug = true;
CloudPush.retrieveDeviceToken({
success: deviceTokenSuccess,
error: deviceTokenError
});
function deviceTokenSuccess(e) {
deviceToken = e.deviceToken;
loginDefault();
}
function deviceTokenError(e) {
console.log('Failed to register for push notifications! ' + e.error);
alert('Failed to register for push notifications! ' + e.error);
}
function loginDefault(e) {
Cloud.Users.login({
login: 'test@gmail.com',
password: 'TESTabc123'
}, function (e) {
if (e.success) {
defaultSubscribe();
// alert("Successfully Loged In");
} else {
// alert('Error login-----: ' + ((e.error && e.message) || JSON.stringify(e)));
}
});
}
function defaultSubscribe() {
Cloud.PushNotifications.subscribe({
channel: 'test1',
device_token: deviceToken,
type: 'android'
}, function (e) {
if (e.success) {
alert('Device Subscribed!');
} else {
alert('Error defaultSubscribe : ' + ((e.error && e.message) || JSON.stringify(e)));
}
});
}
CloudPush.addEventListener('callback', function (evt) {
alert("Notification received: " + 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)');
});
-----------------------------------------------------------------------------------------------------------------------------
index.js
$.index.open();
function NEWWIN(e){
Alloy.createController("Newwin").getView().open();
$.index.close();
}
-----------------------------------------------------------------------------------------------------------------------------
index.xml
-----------------------------------------------------------------------------------------------------------------------------
Newwin.js
var args = $.args;
function BACKUPINDEX(e){
Alloy.createController("index").getView().open();
$.container.close();
}
-----------------------------------------------------------------------------------------------------------------------------
Newwin.xml
-----------------------------------------------------------------------------------------------------------------------------
Hello, Please attach an app folder in here. With your sample code I end up with the
[INFO] [app.js] Titanium entry point processing...
[ERROR]
[ERROR] Alloy compiler failed
Thanks.
Gabriel Gallardo 2017-07-26
The problem occurs at the time of closing the window from which it subscribes to push notifications, Titanium should persist CloudPush even when you close the window from which it was instantiated, please provide a solution for that problem...
Riduanul Islam 2019-08-20
Is there any progress for this issue? It's being long so we can update to customer.
Thank you.
Hello, Please attach an app folder in here. With your sample code I end up with the [INFO] [app.js] Titanium entry point processing... [ERROR] [ERROR] Alloy compiler failed Thanks.
The problem occurs at the time of closing the window from which it subscribes to push notifications, Titanium should persist CloudPush even when you close the window from which it was instantiated, please provide a solution for that problem...
Is there any progress for this issue? It's being long so we can update to customer. Thank you.