Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question]: Custom data {custom_data} parameter is missing! #939

Open
2 of 3 tasks
abhishekr77 opened this issue Aug 21, 2024 · 2 comments
Open
2 of 3 tasks

[question]: Custom data {custom_data} parameter is missing! #939

abhishekr77 opened this issue Aug 21, 2024 · 2 comments

Comments

@abhishekr77
Copy link

What happened?

I am trying to navigate to specific page which needs ID, which i have to pass through the custom_data.

This is the rest-API Payload:

{
"app_id": "appId",
"headings": {"en": "Low Stock❗"},
"priority":"high",
"target_channel": "push",
"include_aliases":{
"external_id": [
"XXXXXXXXXXXXXX"
]
},
"big_picture": "https://media.onesignal.com/automated_push_templates/feature_announcement_template.png",
"android_channel_id": "58bf147a-35de-4914-92f1-1ab9898ff66d",
"template_id": "27429e2c-25b4-4629-81be-1a897a32e778", // works when content_available is false, you can swt template with image
"content_available": false,
"custom_data": {
"item_name": "Mango",
"small_icon":"https://media.onesignal.com/automated_push_templates/feature_announcement_template.png",
"itemId":"12"
}
}

Implementation on flutter side:

OneSignal.Debug.setLogLevel(OSLogLevel.verbose);
OneSignal.initialize("api_key");
OneSignal.Notifications.requestPermission(true);
OneSignal.Notifications.addClickListener((event) {
print(
'NOTIFICATION CLICK LISTENER CALLED WITH EVENT: ${event.notification.jsonRepresentation().replaceAll("\n", "\n")}');
});

Response:
custom data: {google.delivered_priority: normal, google.sent_time: 1724257118981, google.ttl: 259200, google.original_priority: normal, custom: {"i":"8c06af37-c521-4361-957d-fd560b1ada05","a":{""deepLink"":"{{ message.custom_data.small_icon }}"},"ti":"27429e2c-25b4-4629-81be-1a897a32e778","tn":"item low stock "}, google.product_id: 111881503, pri: 6, vis: 0, chnl: {"nm":"New Orders","id":"OS_58bf147a-35de-4914-92f1-1ab9898ff66d","dscr":"new order notifications","grp_id":"OS_cbda6537-bd6c-4f97-bf47-7cccf4c57070","grp_nm":"OrderPe"}, from: 29331827621, alert: Mango-(12) is low in stock, click to manage, bicon: https://media.onesignal.com/automated_push_templates/feature_announcement_template.png, licon: https://media.onesignal.com/automated_push_templates/feature_announcement_template.png, sicon: ic_stat_onesignal_default, title: Low Stock❗, google.message_id: 0:1724257118991720%1bdee165f9fd7ecd, google.c.sender.id: 29331827621, androidNotificationId: 1043054470}

I am not getting the custom_data parameter in the response, can anyone tell what i am doing wrong

Steps to reproduce?

1. Try to send custom_data from rest-api and handle on click method.

What did you expect to happen?

the response supposed to have custom_data so i can handle it from flutter side.

OneSignal Flutter SDK version

5.2.3

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@abhishekr77
Copy link
Author

{ "alert": "Mango-(12)" is low in stock, click to manage"}, i have managed to get some values by using liquid Syntax. And i am passing through templates.
Screenshot 2024-08-22 at 11 16 32 AM.

But when i am trying the same in additional data like this :
Screenshot 2024-08-22 at 11 17 34 AM
i am getting response like this {""deepLink"":"{{ message.custom_data.small_icon }}"}. But i need to pass custom data in this field so i can handle at Notifications.addClickListener((event) .

@abhishekr77 abhishekr77 changed the title [Bug]: Custom data {custom_data} parameter is missing! [question]: Custom data {custom_data} parameter is missing! Aug 23, 2024
@Parthajeet-Sarmah
Copy link

I am having the same issue for React Native. No custom_data property is visible. Did anyone find a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants