jI want to observe inserting and removing photos.
So, I called register PHPhotoLibrary in applicationDidEnterBackground
but, photoLibraryDidChange is called only once or twice
How can I ovserve all changes when my app is in background?
jI want to observe inserting and removing photos.
So, I called register PHPhotoLibrary in applicationDidEnterBackground
but, photoLibraryDidChange is called only once or twice
How can I ovserve all changes when my app is in background?
Fetch the assets that you care about via some fetch API, like this one to fetch all assets in the library. Maintain a reference to this fetch result (in the object that cares) for as long as you care about observing its contents
Register for changes on the PHPhotoLibrary
Respond to changes in photoLibraryDidChange. This basically means:
Ask the PHChange instance for changes related to your fetch result via this API, which will return nil if the change doesn't involve your fetch result
If non-nil, the returned PHFetchResultchangeDetails should tell you exactly what has been inserted/removed/changed
Typically, you'll want to discard your existing PHFetchResult and replace it with the change details' fetchResultAfterChanges. Remember, fetch results are effectively immutable arrays so the old instance will become stale if the library changes