Recently, React native have released Headless JS to run javascript in backgrond. If it is implemented, We can process the notification in background.
Problem which I'm facing is...
I can't receive the notification in the background, If the javascript layer is killed in the background. I think, Headless js will solve the problem.
Hi @sriraman. I believe you meant that you couldn't get the received event to work when the app is killed, but you'll still be able to receive the notification on the native side. I'll definitely look into the Headless JS option to see if we can handle it better.
Thanks!
This might be possible with a content-available notification however I am concerned about battery life and memory pressure this would bring starting up the javascript runtime each time a notification is received. content-available notification have a number of restrictions as well such as not working after force-quitting (swiping away the app) or if Background App Refresh is disabled by the user.
Since iOS 10 the correct and reliable way to handle this is with a UNNotificationServiceExtension. However this runs as a process on it's own and iOS has a very restrictive 5MB RAM limit on this kind of target so it won't be possible to run javascript here.
@sriraman Is the goal to retrieve unopened notifications in your app when the user opens your app again later?
Thanks.
@jkasten2 Yes.. I just want to retrieve the unopened notification when user opens the app.
@avishayil has there been any update on this?
@sriraman @michaelduminy As far as starting the app as Headless JS to process notifications in the background this won't be the correct direction due to the limitations / reliable I described above.
However we plan to provide a feature part of our iOS SDK to store notifications and allow them to be queried once your app is reopened. This is something that will need to be implemented in the base native SDK and then this one. Unfortunately I don't have an eta on this.
Storing notifications is possible today however with two different options noted in below.
https://documentation.onesignal.com/docs/create-an-activity-feed
Most helpful comment
Hi @sriraman. I believe you meant that you couldn't get the
receivedevent to work when the app is killed, but you'll still be able to receive the notification on the native side. I'll definitely look into theHeadless JSoption to see if we can handle it better.Thanks!