KasemJaffer / receive_sharing_intent

A Flutter plugin that enables flutter apps to receive sharing photos, text and url from other apps.
Apache License 2.0
334 stars 395 forks source link

getInitialMedia doesn't work #339

Open Asanas81 opened 1 week ago

Asanas81 commented 1 week ago

I have tried getInitialMedia in iOS, but it returns empty value

here is my Code try { ReceiveSharingIntent.instance.getInitialMedia().then((List value) { print(value.toString()); ShowDialog.showDialogTitle(context, 'Testdata15', value.toString()); WidgetsBinding.instance.addPostFrameCallback((_) { ShowDialog.showDialogTitle(context, 'Testdata', 'content'); print('getInitialMedia'); setState(() { _sharedFiles.clear(); _sharedFiles.addAll(value); // print(_sharedFiles.map((f) => f.toMap())); if (_sharedFiles.isNotEmpty) { ShowDialog.showDialogTitle(context, 'Testdata12', _sharedFiles.first.path); } else { ShowDialog.showDialogTitle(context, 'Testdata13', 'empty'); }

        // Tell the library that we are done processing the intent.
        // ReceiveSharingIntent.instance.reset();
      });
    });
  });
} catch (e, stackTrace) {
  ShowDialog.showDialogTitle(context, 'Testdata7', e.toString());

  print("Error receiving shared files: $e");
  print(stackTrace);
}

the function ShowDialog.showDialogTitle returns message title (Testdata13 for example) and content (for example 'empty') , so i can test the function in Testversion,because print is not available when the app is started through shared file

class ShowDialog { static Future showDialogTitle(BuildContext context, String title, String content) async { return await showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: Text(title), content: Text(content), actions: [ TextButton( child: Text('OK'), onPressed: () { Navigator.of(context).pop(); // Затваря диалога }, ), ], ); }, ); } }

is there any special settings for iOS to read files when the application is closed