Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the 'Flock' iOS app detect when photos have been taken?

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?

like image 865
mblackwell8 Avatar asked Jan 10 '13 23:01

mblackwell8


People also ask

What happens when you allow an app to access your photos?

Usually, there will be nothing to worry about as apps will purely just use the camera when you request them too. But AVG , a security software company, say a malicious app can secretly turn on your camera and record what's going on around you.

Can you see who a picture was sent to on iPhone?

Select the photo, click the Info button in the toolbar, and look in the Sharing section to see to whom and when the photo was sent. Click the entry in the Sharing section to open an email you've sent, so you can view, edit, or resend it. (If you don't see a Sharing section, you haven't shared the photo.)

What does show in all photos mean on iPhone?

Show in all photos places the current picture you're viewing among all the other pictures taken around that time. For example, you're viewing a featured photo, but when you press show in all photos you can view all the other photos taken around that time frame.


2 Answers

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.

like image 127
2 revs Avatar answered Sep 22 '22 02:09

2 revs


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

like image 24
self.name Avatar answered Sep 20 '22 02:09

self.name