fluttercandies / flutter_photo_manager

A Flutter plugin that provides images, videos, and audio abstraction management APIs without interface integration, available on Android, iOS, macOS and OpenHarmony.
https://pub.dev/packages/photo_manager
Apache License 2.0
684 stars 313 forks source link

[Feature/Question] Notification for changes to the device gallery when app is dead #492

Open vishnukvmd opened 3 years ago

vishnukvmd commented 3 years ago

Currently I'm using flutter_background_fetch to periodically call PhotoManager.getAssetPathList to find photos and videos that were added/modified.

Would it be possible for PhotoManager to accept a function that should be executed each time the device gallery is modified, even if the app is not running?

Thanks again for the great library. Please let me know if I can help.

AlexV525 commented 3 years ago

First, https://github.com/CaiJingLong/flutter_photo_manager#observer .

Second, why would you need a function when an app is no longer alive?

vishnukvmd commented 3 years ago

@AlexV525 Thanks for the response.

In my specific case, I'm building an app like Google Photos, that automatically backs up the photos that you take on your phone.

With the current implementation of the observer, I have to wait for the app to be opened for the photos to be backed up.

If the observer could also execute my callback function whenever a photo is taken, regardless of whether the app is alive or dead, that would greatly simplify the situation.

AlexV525 commented 3 years ago

Is this issue resolved?

vishnukvmd commented 3 years ago

Hey @AlexV525, we've worked around this issue inefficiently by using flutter_background_fetch to periodically call PhotoManager.getAssetPathList.

If adding a JobScheduler to listen for changes in the background is within the scope of this project (as explained here), I would request you to leave this issue open (and perhaps mark it as help needed). But if you think that this is outside the scope of this project, please do close the issue.