6

Flock is a reasonably new iOS app from the guys at Bump, which has an interesting feature. It somehow knows when photos have been taken by another app, notifies the user (in a notification center way), and asks the user to share them into an album. There are other interesting features of course, but I'm particularly interested in this feature for another app that I'm working on.

I can't see how the API facilitates this directly. I looked carefully through the notifications API documentation, and apps can certainly register to show a notification to the user at a future date/time, and thus be opened by the user at that time... but I couldn't find any system notification for when a photo has been taken. The notifications API also allows server-generated notifications, but once-again, I don't know how Flock's server-side could know when the user has taken a photo in a different application.

I installed the app a couple of days back, and I only seem to get the notification when I have taken photos. It doesn't appear to be just a daily reminder.

Any ideas how Flock (and potentially other apps) manage to do this?

mblackwell8
  • 3,065
  • 3
  • 21
  • 23
  • Since few people here probably know what the Flock app is or does, you really should better describe what functionality/behavior you are referring to. – rmaddy Jan 10 '13 at 23:46
  • I agreed with rmaddy, I just searched the App Store and downloaded the app titled "flock" and that app doesn't seem to have to described functionality. There was another called "flock app" which I think is what you're talking about but I'm not willing to create an account just to see. Please post more details to demonstrate what you're talking about. – Mick MacCallum Jan 10 '13 at 23:51

2 Answers2

7

After a couple of days of observing the app's behaviour (and a lot of Googling and bumping into arcane discussions about file locking), I have a strong suspicion of how it works: Flock has simply registered for Significant-Change Location Service, which wakes the app and provides a small processing window when the user changes location. The documentation says:

At wake-up time, your app is put into the background and given a small amount of time to process the location data

I suspect that Flock is checking the image library at that point, and triggering a local notification if photos have been added. This squares with my experience that Flock gives me a local notification ~10 minutes after I leave home... which, in case any of the Bump/Flock devs are reading this, is just about the worst time for me to sort through my photos and share them in an album (perhaps I should use public transport more often).

There are some other interesting SO answers here, here and here... but for the most part they discuss local notifications (which can only be scheduled for a particular time, and will always alert the user at that time, so aren't really background tasks) or the 600 second background processing window afforded to apps that have been shut down by the user (which is certainly a background task, but is clearly not fit for the purpose of running a background task once a day or somesuch).

The Bump devs have also provide some clues to the underlying architecture of the app here.

Community
  • 1
  • 1
mblackwell8
  • 3,065
  • 3
  • 21
  • 23
1

I haven't used this Framework personally, but I did stumble across this documentation when doing research for a client.

Apple Photos Framework Reference

Under the Features & Concepts there is an entry for "Change Observing" which states:

Use the shared PHPhotoLibrary object to register a change handler for the photo entities you fetch. Photos tells your app whenever another app or device changes the content or metadata of an asset or the list of assets in a collection. PHChange objects provide information about object state before and after each change with semantics that make it easy to update a collection view or similar interface.

It appears that you can use the PHPhotoLibrary singleton to registerChangeObserver: on a class of yours (that adopts the PHPhotoLibraryChangeObserver protocol) to receive PHChange objects from the photoLibraryDidChange: method

self.name
  • 2,341
  • 2
  • 17
  • 18
  • do you think there are any chances PHPhotoLibrary will notify changes for inactive app in background? Maybe app should also register for any additional services/features to accomplish this? Just investigating for possible solution – vir us Sep 16 '15 at 19:12