How to schedule notification while app is in the background?


I’m running into an issue which is pretty complex and probably inherent to iOS behavior. I’ve found topics on different websites but none answered my question.

My development is using Ionic + Firebase for a chat app. I would like in the callback of a firebase listener, create a notification to let the user know that a new message arrived, in real time.
I was being able to make it work using the background mode plugin, but the app is rejected on the AppStore because of the “hack” this plugin do.
With some search about what happen and how to make it following the guideline, I have discover that iOS doesn’t allow to run JavaScript when the app is in the background but instead, queue the process until the app come back into foreground.
I checked how to make some native code and to wrap it in a plugin, but I didn’t find a Background Mode in iOS which answer my real time needs (the closest that seems to be an answer would be “fetch”, but the doc say it will wake the app from time to time to run a 30sec max process. And the time-to-time doesn’t fill the real time need).

What I was thinking is to make it happen with Push Notification. I would make my listener on a server, send a push notification in silent mode, once receive I’ll schedule an instant local notification to display it on the client side with some user specific logic wrap into the custom data field of the local notification.
Is it a good way to process ?
Should I need to build a custom plugin as well or phonegap-plugin-push + cordova-local-notification will do the trick ?
Has someone already been able to schedule a local notification while the app was in the background without the background-mode plugin ?

Thanks a lot for sharing ideas and experience about this case.

1 Like

hi, have you solved the issue? I’m currently facing same