I am trying to get push notifications working in a ios React Native app and am half way there. The one problem im having is that my logic for displaying a Notification while the app is in the background doesn't execute until the app becomes active again. I am using Socket.io and listening for events, but the code to handle (say onChat event) doesn't run until the app is active. I have verified that the socket is still connected.
The one things thats weird is that is works in the simulator but not on my device. Maybe there is performance optimizations that halt JS execution while the app is put in the background.
How can i get my JS to execute while the appstate is in the background?
What im doing is calling a function when the event is recieved over the socket and it runs:
PushNotificationIOS.presentLocalNotification({
alertBody: `New Chat: ${chat.message}`,
});