0

Hey all I’m new to the world of Xcode and building apps.

I am wondering if it were possible to have an app run in the background and have it listen to the photos library and if it finds a new photo has been added it would automatically upload that to some type of rest api call without the user having to interact/do it manually?

This will only be used in my household so I’m not looking to get it into the App Store or go through any approval process that apple does if it were going to be in the App Store.

So before I spend too much time looking around - is this possible with iOS 14+? Only thing I have come across that remotely sounds like something that would work would be this PHPhotoLibraryChangeObserver but I’m not sure if the user has to interact with it in order for it to be used or not? I’m open to any suggestions you more experienced Xcode programmers have about the above.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
StealthRT
  • 10,108
  • 40
  • 183
  • 342
  • If you're not going through the store submission process, sure you can theoretically enable one of the background modes intended for another purpose and keep the app running. Note, though, that the entire reason that Apple is so restrictive about keeping apps running in the background is that this is an excellent way to quickly drain your battery. A different approach would be to use a [background task](https://developer.apple.com/documentation/backgroundtasks) (which can run periodically in the background at a time of the choosing of the OS) rather than keeping the app running all the time. – Rob Dec 15 '21 at 20:30
  • Are you using iCloud storage for your photos? If so, you could consider writing a macOS app that does this. Or is the idea that you wanted to write your own replacement for iCloud, e.g. syncing photos like Dropbox app does? – Rob Dec 15 '21 at 20:50
  • @Rob My project is just to gather the newly taken photos (that would also be uploaded to facebook) and store them on my server since facebook has really restricted access to these things via their graph API. Just want 1 area that will house all images from my family and extended family who choose to install the app. – StealthRT Dec 15 '21 at 21:22
  • And the background task sounds like it may work. Just need to look into how to use it and what all its capable of doing. – StealthRT Dec 15 '21 at 21:26
  • My two cents: For me, I'd just use iCloud (or Dropbox). It works out of the box, is simple, and won't kill your batteries, as it is designed for precisely this problem. If I were to write something myself, I'd start a background `URLSession` either when the user fired up the app or if `BGProcessingTask` fired. I only mentioned the background mode for the app because it is literally what you asked, but it's probably the least desirable approach, IMHO. – Rob Dec 15 '21 at 23:35
  • Not all of my family use iCloud. All use Facebook to send their photos to. That’s why I just wanted to have the app upload the photos that they are sending to Facebook anyways. – StealthRT Dec 15 '21 at 23:45

0 Answers0