When sending push via onesignal to a react-native app, if I include data field in notification body it takes almost 26 seconds to reach the device but without data field it reaches within 1-2 seconds only. What can be the cause? I tried sending from node, python and Go backends.
This is the body I'm sending,
// Takes 1-2 seconds to reach
const notificationBody: any = {
headings: { en: "Heading" },
contents: { en: "Message"},
include_player_ids: playerIds,
priority: 10,
};
// Takes 26-30 seconds to reach
const notificationBodyWithData: any = {
headings: { en: "Heading with data" },
contents: { en: "Message"},
content_available: true,
data: data || {},
include_player_ids: playerIds,
priority: 10,
};
I tried searching in the documentation of onesignal as well as in git issues, but couldn't find anything related to this.
Sorry for late answer. I got some help from official OneSignal Discord channel. Actually I was actually handling data only notifications on the native side (android and iOS) for video/audio calling purposes and I found out that I wasn't calling the complete()
method on OneSignal object after processing the notification there on the native side itself. As mentioned in the OneSignal react-native docs
// Complete with null means don't show a notification.
notificationReceivedEvent.complete(notification);
That is what the issue was. It was affecting the normal notifications due to this, but now It's working fine.