I have a error when I invoke a Worklight procedure with the properties for APNS notification, specifically - sound.
The error in Eclipse:
[ERROR ] FWLSE0099E: An error occurred while invoking procedure [project ExamplePushTags]PushTagAdapter/sendNotificationFWLSE0100E: parameters: [project ExamplePushTags] TypeError: Cannot set property "apns" of undefined to "[object Object]" (PushTagAdapter-impl.js#30)
In the navigator (safari) appears this:
{
"errors": [
"Ecma Error: TypeError: Cannot set property \"apns\" of undefined to \"[object Object]\" (PushTagAdapter-impl.js#30)"
],
"info": [
],
"isSuccessful": false,
"warnings": [
]
}
Code of function in my adapter PushTagAdapter-impl.js:
var applicationId = "ExamplePushTags";
function sendNotification (tag, notificationText, url) {
var notification = {};
notification.message = {};
notification.message.alert = notificationText;
notification.target = {};
notification.target.tagNames = [tag];
//set notification properties for APNS
//error in this lines of code
notification.settings.apns = {};
notification.settings.apns.sound = 'sounds-865-fallin.mp3';
WL.Server.sendMessage(applicationId, notification);
WL.Logger.info("Notificacion enviada exitosamente " + JSON.stringify(notification));
return { result: "Notification sent"};
}
Note: If I comment this line, I don't have problems and the notification works but I need sound in each notification.
I am using Worklight 6.2