开发者

Does the iOS let developers do this?

开发者 https://www.devze.com 2023-02-28 09:16 出处:网络
Let\'s say the user leaves the phone on the table. (probably on home screen) A few hours later, he p开发者_如何学Goicks it up.And when it does, the iPhone detects the accelerometer, and it rings.Unfo

Let's say the user leaves the phone on the table. (probably on home screen)

A few hours later, he p开发者_如何学Goicks it up. And when it does, the iPhone detects the accelerometer, and it rings.


Unfortunately, this is not possible. Once the OS goes to the home screen, applications running in the background have a limited set of options.

Read this article for more information: http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html


Not through officially accepted means (i.e. you could do it on a jailbroken phone conceivably). Primarily, you can't run in the background for that purpose. If the app was running in the foreground, you can easily detect motion and perform an activity - but if the phone is left for too long a period without activity, it will sleep.


Unfortunately, the accelerometer is not one of the specified keys in the UIBackgroundModes option in your apps info.plist.

auido, location and voip are the only ones available for now.


short answer: YES

The trick is to make sure the app doesn't get backgrounded when the phone goes to sleep. The other elements like detecting changes in the accelerometer and playing a sound are all standard features.

As for the no sleep solution, it has been asked before, basically is you play a music sample the app will continue running, so perhaps a loop of silence continuously played.


Only if you left an app designed for that purpose running in the foreground.

It won't be possible if your app is running in the background.

0

精彩评论

暂无评论...
验证码 换一张
取 消