4

With PhotoStream on IOS 5, When it detects that the device is plugged in, wifi connected and device is locked, it will start uploading the images to the Photostream.

I'm trying to doing something similar to PhotoStream on iDevice. Is there a way to continue monitor and detects those 3 things (device is plugged, wifi,locked) when the app is suspended? Further more, is there a way to monitor and detect those 3 things, even if the my app is not open? If 3 things met? it will call the my app and start uploading images. Would this be approved by app store?

Justin Boo
  • 10,132
  • 8
  • 50
  • 71
Kevin Nguyen
  • 61
  • 1
  • 4

1 Answers1

3

I know you can check if it is plugged in and if it is connected to wifi

Battery Check:

UIDeviceBatteryState batteryState = [UIDevice currentDevice].batteryState;
if (batteryState == UIDeviceBatteryStateCharging || batteryState == UIDeviceBatteryStateFull) {
    // Your code that writes files to a certain location here
}

Blatantly C&P'ed from Need an API that detects when an iPhone is plugged in

To check from wifi you can use the apple sample for Reachability found here: http://developer.apple.com/iphone/library/samplecode/Reachability/index.html

and intruction to use it can be found here How to check for an active Internet connection on iOS or OSX?

EDIT:

You could use what is described in this tutorial http://mobile.tutsplus.com/tutorials/iphone/ios-multitasking-background-tasks/

And in the backgound check the Battery State then if it's connected to wifi and if it is start uploading.

Community
  • 1
  • 1
Michael Smith
  • 498
  • 2
  • 5
  • 15
  • Curious if anyone knows the answer to the last part - is behavior like this subject to App Store disapproval? – dtmland Jan 03 '17 at 21:59