How can I call Method while app is in background in iOS?

前端 未结 3 1113
臣服心动
臣服心动 2021-01-23 16:18

I have one class name as myClassCalculate have the following method

- (void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)accel         


        
3条回答
  •  星月不相逢
    2021-01-23 17:03

    At WWDC this year they said that accelerometer updates could be observed in the background but I'm not sure how to do it. I think it would be iOS 5 only.

    To do background tasks you need to add them to your info.plist in the UIBackgroundModes key. Here is what's available right now.

    audio The application plays audible content in the background.

    location The application provides location-based information to the user and requires the use of the standard location services (as opposed to the significant change location service) to implement this feature.

    voip The application provides Voice-over-IP services. Applications with this key are automatically launched after system boot so that the application can reestablish VoIP services. Applications with this key are also allowed to play background audio.

    newsstand-content The application processes content that was recently downloaded in the background using the Newsstand Kit framework, so that the content is ready when the user wants it. This value is supported in iOS 5.0 and later.

    external-accessory The application communicates with an accessory that delivers data at regular intervals.

    Try putting location in the plist or using [UIApplication beginBackgroundTaskWithHandler:] This value is supported in iOS 5.0 and later.

提交回复
热议问题