in Flutter "Receive share intent" in IOS not receiving any value
Asked Answered
V

1

7

here Im using Receive_share_intent package to receive data from other apps it works perfetctly on android but in IOS when i share in IOS it Opens the app but no data has been passed it doesn't triggered the StreamSubcriber too Package: receive_sharing_intent this the package i have been using to receive data

here the i try to get value from the ReceiveSharingIntent to _textReceiveIntent for text and _mediaReceiveIntent for media files but both are not getting any values fuctions not event triggered will null or [] empty

_intentDataStreamSubscription =
        ReceiveSharingIntent.getTextStream().listen((String value) {
      _textReceiveIntent(value);
    }, onError: (err) {
      print("getLinkStream error: $err");
    });
    ReceiveSharingIntent.getInitialText().then((String? value) {
      _textReceiveIntent(value);
    });
    // Listen image/video Stream - while app is in foreground
    _intentDataStreamSubscription = ReceiveSharingIntent.getMediaStream()
        .listen((List<SharedMediaFile> value) {
      _mediaReceiveIntent(value);
    }, onError: (err) {
      print("getIntentDataStream error: $err");
    });
    //fetch image/video - while resume from terminate state
    ReceiveSharingIntent.getInitialMedia().then((List<SharedMediaFile> value) {
      _mediaReceiveIntent(value);
    });

here What i expecting is receive data from ReceiveSharingIntent to value pass through the respective medium functions

Verine answered 8/4, 2023 at 10:53 Comment(2)
Hi, did you find out how to make it work. I am currently in the same situation where my Share Extension is opening my Flutter app when I'm trying to share an image but the package is not returning any data.Meant
Also experiencing the same issue. Any solutions?Fixation
D
1

I am sharing only URLs from external apps to my flutter app and it's working perfectly fine on my side

Solution:

add receive sharing intent package to you pubspec.yaml file, there is a trick

IMPORTANT NOTE - to make receive_sharing_intent functional on IOS just dump the fork and use version {{1.4.5}} (don't use ^1.4.5) as versions grater than 1.4.5 doesn't compatible with android's fork and for Android Build use the below mentioned fork as {{1.4.5}} is not compatible with latest Gradle, Kotlin versions

bellow is the fork for android

receive_sharing_intent:
    git:
        url: https://github.com/AyushmanG26/receive_sharing_intent
        ref: master

bellow is the version for IOS

receive_sharing_intent: 1.4.5

Now as I am just receiving URL bellow is the code to receive intent

  Future<void> bindShareIntent(BuildContext context) async {
    // For sharing or opening urls/text coming from outside the app while the app is in the memory
    ReceiveSharingIntent.getTextStream().listen((String value) {
      saveUrl(context, value); // value contains the shared URL
    }, onError: (err) { 
      debugPrint("$err");
    });

    // For sharing or opening urls/text coming from outside the app while the app is closed
    ReceiveSharingIntent.getInitialText().then((String? value) {
      saveUrl(context, value); // value contains the shared URL
    });
  }

I hope you have done other steps already for both android and IOS according to plugin's documentation

If this solution doesn't work, I will share complete implementation for Both android and IOS

Doyledoyley answered 14/2 at 8:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.