有没有办法定期唤醒 ios 应用程序? [英] Is there a way to wake the ios app periodically?

查看:44
本文介绍了有没有办法定期唤醒 ios 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要我的应用每 x 小时唤醒一次,从设备获取数据并将其发送到服务器.

I need my app to wake up every x hours, fetch the data from device and send it to the server.

这是可行的吗?如果我可以实现 voip pushkit 或 fcm?

Is it something doable? If I can implement voip pushkit or fcm?

谢谢.

推荐答案

这在某种程度上可以通过使用 PushKit 的 VoIP 推送通知来实现,VoIP 推送通知不会出现在没有声音和徽章的设备上,因此可以生成此在每个间隔之后并对其进行相应的操作.请参考此链接:

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

您可以做的是,在您的应用程序进入后台或终止之前,您可以收集数据并将其发送到服务器.这可以用这个来完成(参考代码):

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

请记住,您只有 180 秒的时间来完成此后台任务(根据我的研究).

Remember you get only 180sec to do this background task (as per my research).

您可以将其初始化为

application.setMinimumBackgroundFetchInterval(1800).

每次您的应用程序进入后台或终止时,此函数都会收到调用.

Every time your application is brought in the background or terminated this function will get a call.

这篇关于有没有办法定期唤醒 ios 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆