Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[How to use] How to get deleted asset id on change notify #1223

Closed
kennir opened this issue Nov 16, 2024 · 1 comment
Closed

[How to use] How to get deleted asset id on change notify #1223

kennir opened this issue Nov 16, 2024 · 1 comment

Comments

@kennir
Copy link

kennir commented Nov 16, 2024

Platforms

Android

Description

Hello

I need to synchronize the deletion of files in system album with my app, but on Android, the deletion event does not contain the ID of the deleted file.

The methodCall looks like the code below.
{mediaType: 1, type: delete, uri: content://media/, platform: android}

the MethodCall when photo inserted
{mediaType: 1, id: 20492, type: insert, uri: content://media/external/images/media/20492, platform: android, galleryId: -1739773001}

My question is , How to get the id of deletion of photos?

Thank you very much

My code

void _onChangeNotified(MethodCall call) {
    if (defaultTargetPlatform == TargetPlatform.iOS) {
      final delete = List<dynamic>.from(call.arguments['delete']);
      if (delete.isNotEmpty == true) {
        _onPhotosDeleted(delete.map((e) => e['id'].toString()).toList());
      }
      final create = List<dynamic>.from(call.arguments['create']);
      if (create.isNotEmpty == true) {
        _onPhotosCreated(create.map((e) => e['id'].toString()).toList());
      }
    } else if (defaultTargetPlatform == TargetPlatform.android) {
      if (call.arguments['type'] == 'delete') {
        // no id returned ???
      }

      if (call.arguments['type'] == 'insert') {
        final assetId = call.arguments['id'].toString();
        _onPhotosCreated([assetId]);
      }
    } else {
      throw UnsupportedError('Unsupported platform');
    }
  }

Try do it

No response

@AlexV525
Copy link
Member

The call comes from the native platform without extra modifications. There is nothing we can do further from the library side. Here are log samples that might be helpful: https://github.com/fluttercandies/flutter_photo_manager/tree/main/log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants