Ad

Perform An HTTP Request In UNNotificationServiceExtension

I need to call a backend service when my app receives a remote push notification, even when the app is killed. To do this I intercept the notification using a UNNotificationServiceExtension, in the "didReceive" method, and I perform a http request in the body of this method. Is this a dangerous procedure? Can this cause some problems, eg a rejection from the Apple Store?

Ad

Answer

You can definitely do what you want, but remember you only get around 30 seconds and that you need to use a synchronous, not async download. If you use an async download it'll likely be killed as soon as your completion handler calls, which will happen before your download completes.

Ad
source: stackoverflow.com
Ad