fluttercandies / triage_bot_for_flutter_photo_manager

0 stars 0 forks source link

Test - [How to use] How to get deleted asset id on change notify #17

Closed AmosHuKe closed 4 hours ago

AmosHuKe commented 4 hours ago

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

fluttercandies-dev commented 3 hours ago

AI Summary: Android's photo deletion notification lacks the asset ID. The user needs a way to retrieve the ID of deleted photos for synchronization.