First of all thank you for your work with the module.
We have your module working on our app in iOS and Android platform. On iOS everything is working fine (Background and Foreground), but on Android the local notification is shown only when the application is closed pressing the home button.
If we closed the app through the task manager the Local notification is not shown.
Here you can see the fragment of code which we use your module. This code is placed on "app.js" and is called when the app starts:
PushClient = require('br.com.arlsoft.pushclient');
if (Titanium.Platform.name != 'android') {//OS_IOS
var issue17030 = Ti.Network.registerForPushNotifications;
var issue17030iOS8 = Ti.App.iOS.registerUserNotificationSettings;
}
var registerOptions = {
GCMSenderId : '333366674012',
APNTypes : [PushClient.NOTIFICATION_TYPE_BADGE, PushClient.NOTIFICATION_TYPE_ALERT, PushClient.NOTIFICATION_TYPE_SOUND]
};
if (Titanium.Platform.name != 'android') {
var acceptAction = PushClient.createAction({
identifier : 'ACCEPT_IDENTIFIER',
title : 'Accept',
activationMode : PushClient.NOTIFICATION_ACTIVATION_MODE_FOREGROUND,
destructive : false,
authenticationRequired : true
});
var rejectAction = PushClient.createAction({
identifier : 'REJECT_IDENTIFIER',
title : 'Reject',
activationMode : PushClient.NOTIFICATION_ACTIVATION_MODE_BACKGROUND,
destructive : true,
authenticationRequired : false
});
var downloadContent = PushClient.createCategory({
identifier : 'APPROVE_CONTENT',
actionsForMinimalContext : [acceptAction, rejectAction],
actionsForDefaultContext : [acceptAction, rejectAction]
});
registerOptions.Categories = [downloadContent];
}
var eventSuccess = function(event) {
//TODO
};
var eventError = function(event) {
if (!event) {
//alertDialogManagerInstance.showAlert('Error:\n\nInvalid error');
return;
}
switch (event.code) {
case PushClient.ERROR_SENDER_ID:
//TODO
break;
case PushClient.ERROR_PLAY_SERVICES:
//TODO
break;
case PushClient.ERROR_NOT_SUPPORTED:
//TODO
break;
case PushClient.ERROR_REGISTER:
//TODO
break;
case PushClient.ERROR_UNREGISTER:
//TODO
break;
default:
//TODO
}
};
var eventCallback = function(event) {
if (!event) {
// Should never happen...
} else if (event.mode == PushClient.MODE_FOREGROUND) {
// Push data received with app in foreground
//TODO
} else if (event.mode == PushClient.MODE_CLICK) {
//TODO
// Push data received when user clicks in notification message
} else if (event.mode == PushClient.MODE_BACKGROUND) {
// Requires set remote-notification UIBackgroundModes in tiapp.xml
PushClient.endBackgroundHandler(event.data.handlerId);
// Put the application back to sleep before any UI interations
// Push data received with app in background
} else if (event.mode == PushClient.MODE_ACTION) {
// Push data received when userchoose an action from notification message
} else {
// Should never happen...
}
};
PushClient.addEventListener(PushClient.EVENT_SUCCESS, eventSuccess);
PushClient.addEventListener(PushClient.EVENT_ERROR, eventError);
PushClient.addEventListener(PushClient.EVENT_CALLBACK, eventCallback);
If we analyze the logcat when send the notification we can see the next lines:
Hi Arley,
First of all thank you for your work with the module.
We have your module working on our app in iOS and Android platform. On iOS everything is working fine (Background and Foreground), but on Android the local notification is shown only when the application is closed pressing the home button. If we closed the app through the task manager the Local notification is not shown.
The payload we send from the server is this:
Here you can see the fragment of code which we use your module. This code is placed on "app.js" and is called when the app starts:
If we analyze the logcat when send the notification we can see the next lines:
We have test in different version of android (4.4, 5.1 and 6.0) with the same result.
Titanium SDK version is 5.2.0.GA and the lastest version of your module.
¿Do you have an idea of what is going on?
Best regards.