How to add Category to the iOS Push Notification Payload

I want to send an actionable Push Notification(a Notification with a button) from the WebApp through Javascript API. That is I expect the payload to be received on the iOS device as below:

“aps” : {
“alert” : “Pull down to interact.”,
“category” : “ACTIONABLE”
}

I tried setting the category in the publish header options, but that prepares the payload like this:

“aps” : {
“alert” : “Pull down to interact.”,
}“category” : “ACTIONABLE”
which is not what I expect.
So please let me know how to frame the message below in the below API, so that I will end with the Fisrt Payload.
var channel = “default”,

message = “Pull down to interact”,
pubOps = null,
deliveryOps = new DeliveryOptions({
pushPolicy: “PUSHONLY”
});
var response = Backendless.Messaging.publish( channel, message, pubOps, deliveryOps );

Hi Forest,

What if you include the category right into the payload as opposed to using a header? I mean you were able to submit this:

“aps” : {
“alert” : “Pull down to interact.”,
}
Why not adding “category” : “ACTIONABLE” to it?
Regards,
Mark

Hi Mark,

I think there is a misunderstanding. I didn’t frame the payload and it is done by the SDK.

If my JS is,

var channel = “default”,
message = '“Pull down to interact.”,
pubOps = null,
deliveryOps = new DeliveryOptions({
pushPolicy: “PUSHONLY”
});
var response = Backendless.Messaging.publish( channel, message, pubOps, deliveryOps );

it prepares the payload like this.

“aps” : {
“alert” : “Pull down to interact.”
}
So to get the payload as,
“aps” : {
“alert” : “Pull down to interact.”,
“category” : “ACTIONABLE”
}
what should be the JavaScript change that needs to be done from the above? Hope this is clear.
Regards,
Balakrishnan

Have you tried publishing the following object?:

var message = {};
message[ “alert” ] = “Pull down to interact”;
message[ “category” ] = “ACTIONABLE”;

No that doesn’t work. This prepares the payload like this.

“aps” : {
“alert” : “{alert=Pull down to interact, category=ACTIONABLE}”
}

Hi Balakrishnan,

Thanks for checking. Just to make sure we’re reproducing the problem correctly, how do you subscribe to receive the notification? Where exactly do you check the value of the received object?

Regards,
Mark

Hi Mark,

Sorry for the delay in responding. I was out for a long weekend. To receive the push notification I have the below code in AppDelegate.m

  • (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

{

[backendless.messaging didReceiveRemoteNotification:userInfo];

NSLog(@"Inside Notification");

NSLog(@"%@", userInfo);

NSLog(@"%@", [userInfo objectForKey:@"aps"]);

NSLog(@"%@", [[userInfo objectForKey:@"aps"] objectForKey:@"alert"]);

}

Regards,
Balakrishnan

Hi Mark,

Any updates on the issue?

Regards,
Balakrishnan

Hi Balakrishnan,

We’re making the changes to make this happen. It will be in one of the near term releases.

Regards,
Mark

Hi Mark,

Thanks for considering to support actionable notifications. Please let me know when the release is out.

Regards,
Balakrishnan

Hello Mark and Forrest Gump

I’m having the same problem.
category and content-available (other key) must be within the aps {}
Backendless sends the category but off after {}

Hey guys,

You can use the following header:

“ios-content-available”:“1”

This will get the “content-available” header into the “aps” object.

As for the “ios-category” header, it will be supported in the release of Backendless which we will roll out this coming week.

Regards,
Mark

Hi,

Does this also cover loc-key which is used in iOS to send localised alert text (localisation controlled by the app instead of the server needing to know all localisations)?

The docs at https://backendless.com/documentation/messaging/android/messaging_publish_push_notifications.htm don’t cover that or the items above for category and content available.

Thanks

Hi Mark,

Is the “ios-category” header added to support? If Yes, what I have to do to make it available for an already existing backendless project.

Mark,

Can you respond to this?

The dev team has reported to me that ios-category works when you run an app on iOS-9. However, with the changes in iOS10, it arrives, but is not visualized properly. We’re investigating that issue.

Mark

Anything new regarding ios-category on iOS9 & iOS10 devices ?!