You need to sign in to do that
Don't have an account?
push notification banner is not visible in mobile device
I am trying to send push notification to android mobile device.
I am using trigger to send push notification to mobile device and notification is received but not notification banner is not visble. I think the problem is payload sturcture
whatever I am sending from salesforce trigger it is going in
notification:{ data:{ /* here.... */ }}
FCM is expecting JSON like this
notification: { title: 'title', message: 'message', data:{},...}
here is my apex code
Messaging.PushNotification msg = new Messaging.PushNotification();
Map<String, Object> androidPayload = new Map<String, Object>();
Set<String> userSet = new Set<String>();
androidPayload.put('title','title');
androidPayload.put('message', subject);
androidPayload.put('parentId', str[4].trim());
androidPayload.put('id', str[0].trim());
androidPayload.put('objectName', 'Task');
androidPayload.put('record', str[5]);
userSet.add(accIdVSuserId.get(accId));
msg.setPayload(androidPayload);
msg.send('connected_app', userSet);
Refer below salesforce help article for information on this.
https://help.salesforce.com/articleView?id=000194290&type=1
For further reference, you can check the below,
https://stackoverflow.com/questions/45234746/android-push-notification-banner-not-showing-up-in-some-devices
I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.
Thanks.
Hi Abhishek,
Thanks for your reply. I already gone thrrough this link https://help.salesforce.com/articleView?id=000194290&type=1
I came to the conclusion that salesoforce push notification payload is corresponding to a "data only" notification. that is why notification banner is not visible, I am using localnotification to show the banner but this solution s not working when app is closed
Is there a way to change the payload structure ?