You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can I initiate an http request in setBackgroundMessageHandler without waiting for it response ?
We have configured the messaging().setBackgroundMessageHandler. According to apple docs the time that the handler take is very important for the following decisions wherever to launch the app or not.
As soon as you finish processing the notification, you must call the block in the handler parameter or your app will be terminated. Your app has up to 30 seconds of wall-clock time to process the notification and call the specified completion handler block. In practice, you should call the handler block as soon as you are done processing the notification. The system tracks the elapsed time, power usage, and data costs for your app’s background downloads. Apps that use significant amounts of power when processing remote notifications may not always be woken up early to process future notifications. https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623013-application?language=objc
Our background handler looks something like this:
messaging().setBackgroundMessageHandler(async(remoteMessage)=>{awaitnotifee.incrementBadgeCount()constdisplayedNotifications=awaitnotifee.getDisplayedNotifications().catch(()=>[]);if(Platform.OS==='ios'){// some async logic (workaroud for long sound on ios)}if(Platform.OS==='andorid'){// some async logic (workaround: cancel older notification than X)}awaitkeycloak.init(...)const{ data, notification }=remoteMessage;if(data?.type==='NEW_ORDER'){awaitapi().markOrderAsReceived({orderId: data.orderId}).catch(()=>{});// <-------- here we make the http requestreturn;}if(notification){// If the message contains a notification property, it is automatically// handled by the OS when the app is not active. There is nothing you// can do to prevent that.return;}// Custom notificationif(data?.notifee){notifee.displayNotification(JSON.parse(data.notifee));return;}});
So the question is: Do we have to wait for the http request or I can initiate it and forget about it ? I am afraid of the OS releasing the resources and somehow canceling the http request.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Can I initiate an http request in setBackgroundMessageHandler without waiting for it response ?
We have configured the
messaging().setBackgroundMessageHandler
. According to apple docs the time that the handler take is very important for the following decisions wherever to launch the app or not.Our background handler looks something like this:
So the question is:
Do we have to wait for the http request or I can initiate it and forget about it ? I am afraid of the OS releasing the resources and somehow canceling the http request.
Beta Was this translation helpful? Give feedback.
All reactions