I need my app to wake up every x hours, fetch the data from device and send it to the server.
Is it something doable? If I can implement voip pushkit or fcm?
Thanks.
Request the system to launch your app in the background to run tasks.
Refreshing and Maintaining Your App Using Background Tasks
This can somewhat be achieved by VoIP push notifications using PushKit, VoIP push notifications don't appear on a device with no sounds and badges, so one can produce this after every interval and do respective actions on it. Refer to this link:
https://medium.com/mindful-engineering/voice-over-internet-protocol-voip-801ee15c3722
OR
What you can do is before your application goes in the background or terminated you can collect the data and send it to the server. This can be done with this(refer to the code):
https://www.hackingwithswift.com/example-code/system/how-to-run-code-when-your-app-is-terminated
Remember you get only 180sec to do this background task (as per my research).
You can initialize this as
application.setMinimumBackgroundFetchInterval(1800) .
Every time your application is brought in the background or terminated this function will get a call.
You cannot do it periodically, but you can do it using VOIP Pushkit, through help of server. But I am not sure if apple allows VOIP without calling feature.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.