iOS - 在应用程序处于挂起状态时运行后台进程

时间:2020-12-10 01:25:46

I have an application which takes characters from a web page and compares them to a UILabel in the application. What I want to do is enable the app to continue to do this even when the user has placed the app in a suspended state. All I have found online and in the documentation is the way to schedule a UILocalNotification while still in the active state. In the documentation, it states that you can declare certain permissions in the info.plist. I looked at the categories, but my application cannot really fit any of those. Is there a way for me to continue comparing the two strings and scheduling a notification while in the background? Thanks.

我有一个应用程序,它从网页中获取字符并将它们与应用程序中的UILabel进行比较。我想要做的是即使用户将应用程序置于挂起状态,也可以让应用继续执行此操作。我在网上和文档中找到的所有内容都是在处于活动状态时安排UILocalNotification的方法。在文档中,它声明您可以在info.plist中声明某些权限。我查看了类别,但我的应用程序不能真正适合这些类别。有没有办法让我继续比较两个字符串并在后台安排通知?谢谢。

1 个解决方案

#1


0  

iOS doesn't really support multi-tasking in the manner you require. (i.e.: You can't simply carry on processing data in the background unless you're a very specific kind of app such as a VOIP service, etc.) otherwise you're likely to end up being terminated.

iOS并不真正支持您需要的多任务处理。 (即:你不能简单地在后台继续处理数据,除非你是一个非常特殊的应用程序,如VOIP服务等),否则你很可能最终被终止。

However, one possible solution would be to carry our this monitoring on a separate system (e.g.: a web server that your app interacts with) rather than within the app itself. You'd therefore:

但是,一种可能的解决方案是在单独的系统(例如:您的应用与之交互的Web服务器)上进行此监控,而不是在应用程序本身内。你因此:

  1. Communicate the required string/web page to your web service

    将所需的字符串/网页传递给您的Web服务

  2. Carry out the processing on the web server.

    在Web服务器上执行处理。

  3. Send a push notification to your app if the string was found on the page in question.

    如果在相关页面上找到字符串,则向您的应用发送推送通知。

#1


0  

iOS doesn't really support multi-tasking in the manner you require. (i.e.: You can't simply carry on processing data in the background unless you're a very specific kind of app such as a VOIP service, etc.) otherwise you're likely to end up being terminated.

iOS并不真正支持您需要的多任务处理。 (即:你不能简单地在后台继续处理数据,除非你是一个非常特殊的应用程序,如VOIP服务等),否则你很可能最终被终止。

However, one possible solution would be to carry our this monitoring on a separate system (e.g.: a web server that your app interacts with) rather than within the app itself. You'd therefore:

但是,一种可能的解决方案是在单独的系统(例如:您的应用与之交互的Web服务器)上进行此监控,而不是在应用程序本身内。你因此:

  1. Communicate the required string/web page to your web service

    将所需的字符串/网页传递给您的Web服务

  2. Carry out the processing on the web server.

    在Web服务器上执行处理。

  3. Send a push notification to your app if the string was found on the page in question.

    如果在相关页面上找到字符串,则向您的应用发送推送通知。