Extension-push platform discrepancy

I’ve noticed a discrepancy between iOS and Android behaviour for the payload received by the listener registered with extension-push.
In the sample project, on Android, the following is printed:

DEBUG:SCRIPT: Push payload received: (activated: false)
DEBUG:SCRIPT: data = {
field2 = Other value,
field = Some value,
}

whereas on iOS it’s:

DEBUG:SCRIPT: Push payload received: (activated: false)
DEBUG:SCRIPT: payload = {“data”:{“field”:“Some value”,“field2”:“Other value”}},
id = 2,

Effectively, Android gives me payload.payload
It’s easy enough to handle, but I wonder if it would be considered a bug?

It also seems like on iOS you get the JSON as a string as opposed to a Lua table?

Yes, but it’s not just that.

In both cases, type(payload) == “table”
On iOS, that table has a string member called “payload” which is the JSON-encoded payload. It also supplies the id.
On Android, the table is the payload, and I don’t get the id.

1 Like

How are you sending the remote notification? I’m a bit confused by payload and where that’s coming from. Or is this a local notification?

It’s a local notification triggered by the ‘Local 10s’ button in the extension-push sample which converts the received payload to a string and displays it in the GUI - device screenshots below.
iOS
iOS
Android
Android

1 Like

Ah, ok, a local notification. It looks like there is an issue in the extension code where we associate the payload with the key “payload” in the NSMutableDictionary here:

But later when we receive the local notification we take the whole notification and serialize it back to JSON:

I believe we should grab only the payload from the userInfo dictionary, ie replace:

cmd.m_Result = ObjCToJson(notification.userInfo);

with:

cmd.m_Result = ObjCToJson(notification.userInfo[@"payload"]);

I haven’t had time to test this myself though. Perhaps you could give it a try?

1 Like

That crashes, and unfortunately I don’t know enough Objective-C to do anything with it.
Just to mention, I am working around if for now, so it isn’t urgent.

1 Like

I’m going to take a look at it now anyway!

1 Like

Thanks. Also, I haven’t tested push (remote) notifications on iOS, so it’s possible they have the same problem.

FYI: We released a fix yesterday.

2 Likes

Thanks, I’ll take a look.

1 Like