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 allow to share only specific files types ? #325

Open
tempo-riz opened this issue Sep 24, 2024 · 2 comments
Open

How to allow to share only specific files types ? #325

tempo-riz opened this issue Sep 24, 2024 · 2 comments

Comments

@tempo-riz
Copy link

I want to recieve only audio files (public.audio)
How can i show my app in the dialog only for audio files please ?

@CodingCrog
Copy link

CodingCrog commented Oct 15, 2024

You can differentiate between mimetypes, I did it to not break my other deeplinks like:

`void subscribeIntentDataStream() {
if (_intentSub != null) {
return;
}
_intentSub = ReceiveSharingIntent.instance.getMediaStream().listen((value) {
bool isSharedMedia = value.any((item) =>
item.mimeType.toString().startsWith('image') ||
item.mimeType.toString().startsWith('video') ||
item.mimeType.toString().startsWith('document') ||
item.mimeType.toString().startsWith('text'));

  if (value.isNotEmpty && isSharedMedia) {
      Messenger.initShareMedia(value);
    _navigateToSharedMediaPage();
  }
}, onError: (err) {
  Logger.logError("getIntentDataStream error: $err");
});

}

In your case you can look if its an audio:
item.mimeType.toString().startsWith('audio')

@tempo-riz
Copy link
Author

Thanks @CodingCrog but I was looking for a step before, if possible to allow only to share audio, with your solution users will be able to share any filetype, but if it's not audio it will just open the app and do nothing. I don't know if that's possible tho...

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

No branches or pull requests

2 participants