Hi @yrmal,
When the app is terminated:
- The OS (iOS/Android) does not allow background code execution.
- Timers and background services are stopped, so you cannot automatically refresh the push notification subscription.
- This means your app will stop receiving ACS chat push notifications once the 45-minute subscription window expires, unless the user manually reopens the app.
To ensure the push notification subscription remains valid after the app is terminated, consider the following approach:
- When you create or renew the subscription, save the timestamp of the renewal in local storage (like
SharedPreferences
on Android orUserDefaults
on iOS). Also, store the token or registration state if needed for comparison later. - When the app starts up (after being terminated), immediately check if the subscription is expired or close to expiring (e.g., more than 40 minutes old). If it is, renew the push notification subscription right away to resume receiving messages.
- Unfortunately, messages sent during the window when the app was terminated, and the subscription expired will not be delivered. However, once the user opens the app again, you can resubscribe and start receiving new notifications as normal.
- Unfortunately, there is no way to automatically renew the subscription while the app is terminated, because push subscription management requires the app to execute code, and iOS/Android do not allow this from a terminated state.
https://learn.microsoft.com/en-us/azure/communication-services/concepts/notifications
https://learn.microsoft.com/en-us/azure/communication-services/concepts/chat/concepts
https://developer.android.com/guide/components/activities/activity-lifecycle
https://developer.apple.com/documentation/uikit/managing-your-app-s-life-cycle
Hope the above provided information was helpful, if you have any further concerns or queries, please feel free to reach out to us.