简体   繁体   English

如何知道我的应用目前是否在ios中使用

[英]How to know if my app is currently used in ios

I want to perform a task continuously in my iOS application. 我想在我的iOS应用程序中不断执行任务。 If my application is in the foreground, it's working as expected. 如果我的应用程序在前台,它正在按预期工作。 But the moment it enters into the background or is in sleep mode, it stops working. 但是当它进入后台或处于睡眠模式时,它就会停止工作。

How can I implement this in iOS? 我如何在iOS中实现这一点?

You can use the Finite-Length tasks to execute some task when your app is going in to the background. 当您的应用程序进入后台时,您可以使用有限长度任务来执行某些任务。 This will allow your app the to finish a task with a given time (10min. max). 这将允许您的应用程序在给定时间内完成任务(最多10分钟)。

The other option is to look if your app falls in any of the background modes . 另一种选择是查看您的应用是否属于任何后台模式 But be aware that is you misses the background mode to keep you app a live in the background apple will reject your app. 但要注意的是,你错过了背景模式让你的应用程序在后台运行苹果将拒绝你的应用程序。

If the task is an update task, like to retrieve new information, you should move this task to a server and use Push Notifications to alert the user of update. 如果任务是更新任务,比如要检索新信息,则应将此任务移至服务器并使用推送通知来提醒用户更新。 You can even combine it with a background fetch which will allow you app the retrieve the information in the background. 您甚至可以将它与后台提取相结合,这将允许您应用程序在后台检索信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS:有没有办法知道当前的iOS用户是否曾经使用过我的应用 - iOS: Is there a way to know if the current user of iOS ever used my app 在运行我的iPhone应用程序时,如何知道正在使用的IOS? - How do I know what IOS is being used, when running my iPhone app? iOS,如何知道在iOS Appstore中使用哪个帐户购买应用程序? - iOS , How to know which account was used to buy app in ios appstore? Facebook iOS应用程序-如何了解授权我的Facebook应用程序的用户 - Facebook iOS app - How to know the users that authorize my Facebook app 我如何知道我的 iOS 应用程序的蜂窝网络访问是否被禁用? - How do I know if cellular access for my iOS app is disabled? iOS Javascript:如何知道终止后是否打开我的应用程序? - iOS Javascript: How to know if my app is opened after termination? 我的iOS应用程序如何知道Appium正在运行它? - How can my iOS app know Appium is running it? 如何知道我的iOS应用程序是否具有正确的Bundle ID? - How to know if my iOS app has the correct Bundle ID? 如何知道哪个用户登录了我的ios应用 - how to know which user has logged in to my ios app 如何知道 iOS 会杀死我的应用扩展 - How to know that iOS is going to kill my app extension
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM