[OneSignal Plugin] Notification RawPayload

[OneSignal Plugin] Notification RawPayload

  
Forge Component
(5)
Published on 28 Mar (4 weeks ago) by OutSystems R&D
5 votes
Published on 28 Mar (4 weeks ago) by OutSystems R&D

Im trying to use the RawPayload from the notification, however the behavior in iOS is different from android.


For the android it displays the raw text json as shown on the screenshot below


but for the the iOS it returns object and not the raw json text shown on the image below


What I need is to get the raw json text just like in android. hoping for this to be answered the soonest :)


Thank you,


Hello Royce,

From what I could gather, this is most probably due to the underlying differences between the Android Native SDK and iOS Native SDK from OneSignal itself. 

While on Android the rawPayload property of the OSNotificationPayload class is a string, which maps directly to the OutSystems structure attribute of type Text, on the iOS the same property of the OSNotificationPayload class has the type NSDictionary, which doesn't map directly to a Text attribute (hence the "[object Object]").

Either the OutSystems OneSignal Plugin adds some processing to handle the iOS case differently from the Android one, or this OneSignal SDK difference will prevent you from using the value in iOS. 

What was your use case for the raw payload? Can you handle it differently without relying on this structure attribute?

Regards,
Pedro

Pedro Sousa wrote:

Hello Royce,

From what I could gather, this is most probably due to the underlying differences between the Android Native SDK and iOS Native SDK from OneSignal itself. 

While on Android the rawPayload property of the OSNotificationPayload class is a string, which maps directly to the OutSystems structure attribute of type Text, on the iOS the same property of the OSNotificationPayload class has the type NSDictionary, which doesn't map directly to a Text attribute (hence the "[object Object]").

Either the OutSystems OneSignal Plugin adds some processing to handle the iOS case differently from the Android one, or this OneSignal SDK difference will prevent you from using the value in iOS. 

What was your use case for the raw payload? Can you handle it differently without relying on this structure attribute?

Regards,
Pedro

Hi Pedro,

Thank you for your response, I'm using the rawPayload to extract custom data from the push notification. any recomendation on how should I handle it?

I'm using a POST action on my cms to send the notification with this payloads

{
  "app_id": "the-app-id",
  "included_segments": ["All"],
  "include_player_ids": ["player-id"],
  "data":{"refno":"value"},
  "url":"http://sample.com/",
  "contents": {"en": "English sample!"},
  "headings":{"en":"This is a title"},
  "big_picture": "",
  "small_icon": "",
  "isAndroid":false
}

I'm trying to extract the refno value from the push notification. 

Thank you, 


Hello, Royce,

At first glance, that looks like a bug. Could you get in touch with us via a support case, so we can have a better look and follow-up if it is indeed the case?

In the meantime, maybe you could try using a JS node and use the typeof function to determine if rawPayload is a string or an object? And if the latter, use "JSON.stringify" to convert the Object into a string, matching the expected type?

Best regards,

Carlos Simões