简体   繁体   中英

wake up app after terminate

i want to wake up my app after app terminated using background modes... i know using location update and push notifications we can do.but i don't to use those. apart from those is their any way to wakeup my app.

actually i need to connect my app with websocket even app was terminated.

is their any way to wakeup app using core motions. or using microphone(i mean if app catches any data of voice(sound))..

can any one explain app life cycle (when it will wakeup and when it will sleep)

thanks u

Even if there is a way (actually there are some tricks with beacons but user would have to be in the range of beacon specified by you) it shouldn't be used like so.

If your app is kind of weather service or newsfeed, iOS device will be woken up at intervals specified by you (not less than 1h) to check for necessary data.

Using microphone or core motion to wake up your app probably won't pass apple review.

To fully answer your question I would have to know reason for background mode.

According to your requirement "i need to track device motion activity", you could use the queryActivityStarting() provided by apple API's . This gathers and returns historical motion data for the specified time period:

let activityManager = CMMotionActivityManager()
activityManager.queryActivityStarting(from: lastTimeAppCollectedData, to: now, to: queue) { (activities, error) in}

This returns you an array of activities/error that happened in the given period

It still wont wake your app up, but will allow you to query the events after they happened.

You can use CLRegion for geofencing as soon as user exit the region boundary, your app will get open with didExit delegate of CLRegion and after that you can use startActivityUpdates of CMMotionActivityManager to keep your app open till you want.

Resources: Region Monitoring

No once app is terminated you don't have any access to app until app is opened by user. Even location update and push notifications only work in background.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM