objective-c 如何在 iphone 后台运行我的应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1547477/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 22:20:08  来源:igfitidea点击:

how to run my application in background in iphone?

objective-ciphonebackground-process

提问by Rahul Vyas

I want to run my timer in background even when app is not running. Because I want to get gps cordinate of the user after some time interval. What is the method to do this?

即使应用程序未运行,我也想在后台运行我的计时器。因为我想在一段时间后获得用户的 gps 坐标。这样做的方法是什么?

回答by Artelius

I don't think this is allowed in the iPhone programming paradigm. The operating system is capable of running background tasks but ordinary iPhone apps are not permitted to launch anything like this.

我认为这在 iPhone 编程范式中是不允许的。该操作系统能够运行后台任务,但不允许普通的 iPhone 应用程序启动此类任务。

回答by Ed Marty

The Apple Push Notification service is not, in fact, only available to a few developers. It is currently in wide-spread use.

实际上,Apple 推送通知服务并非仅对少数开发人员可用。目前它被广泛使用。

Take a look at this:

看看这个:

http://developer.apple.com/IPhone/library/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html

http://developer.apple.com/IPhone/library/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html

The "Registering for remote notifications" section specifies how to register for push notifications. The other end is set up in the iPhone developer portal.

“注册远程通知”部分指定了如何注册推送通知。另一端设置在 iPhone 开发者门户中。

回答by Mobs

Not possible without jailbreak - iphone sdk apps can only run while on screen.

没有越狱是不可能的 - iphone sdk 应用程序只能在屏幕上运行。

回答by Dave

You could contact the people who made this

你可以联系制作这个的人

http://appadvice.com/appnn/2008/10/run-iphone-apps-in-the-background/

http://appadvice.com/appnn/2008/10/run-iphone-apps-in-the-background/

It only works on jail broke phones, another way it to use push notification from our servers for timed tasks. Why dont you use this, to wake up the app get the GPS then send it back to sleep. Better for batteries too.

它仅适用于越狱手机,另一种使用来自我们服务器的推送通知来执行定时任务的方式。你为什么不使用它,唤醒应用程序获取 GPS 然后将其发送回睡眠状态。对电池也更好。

回答by Xeieshan

May be the link will Help bcz u might have to implement the code in Appdelegate in app run in background method .. Also consult the developer.apple.com site for application class Here is link for runing app in background http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html

可能是链接将帮助 bcz 你可能必须在后台运行的应用程序中实现 Appdelegate 中的代码..另请参阅 developer.apple.com 站点以获取应用程序类 这里是在后台运行应用程序的链接 http://developer。 apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html

回答by mreyesc

I think you are in one of cases you can do background process, take a look in this discusion

我认为您处于可以进行后台处理的情况之一,请查看此讨论

Run app for more than 10 minutes in background

在后台运行应用程序超过 10 分钟