diff --git a/README.md b/README.md index fb778cf2..c305688a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # receive_sharing_intent -A flutter plugin that enables flutter apps to receive sharing photos from other apps. +A flutter plugin that enables flutter apps to receive sharing photos, text and urls from other apps. Also, supports iOS Share extension and launching the host app automatically. Check the provided example for more info. diff --git a/android/src/main/kotlin/com/kasem/receive_sharing_intent/ReceiveSharingIntentPlugin.kt b/android/src/main/kotlin/com/kasem/receive_sharing_intent/ReceiveSharingIntentPlugin.kt index 306324cf..4d59a461 100644 --- a/android/src/main/kotlin/com/kasem/receive_sharing_intent/ReceiveSharingIntentPlugin.kt +++ b/android/src/main/kotlin/com/kasem/receive_sharing_intent/ReceiveSharingIntentPlugin.kt @@ -19,13 +19,13 @@ class ReceiveSharingIntentPlugin(val registrar: Registrar) : PluginRegistry.NewIntentListener { private var changeReceiverImage: BroadcastReceiver? = null - private var changeReceiverLink: BroadcastReceiver? = null + private var changeReceiverText: BroadcastReceiver? = null private var initialIntentData: ArrayList? = null private var latestIntentData: ArrayList? = null - private var initialLink: String? = null - private var latestLink: String? = null + private var initialText: String? = null + private var latestText: String? = null init { handleIntent(registrar.context(), registrar.activity().intent, true) @@ -34,14 +34,14 @@ class ReceiveSharingIntentPlugin(val registrar: Registrar) : override fun onListen(arguments: Any?, events: EventChannel.EventSink) { when (arguments) { "image" -> changeReceiverImage = createChangeReceiver(events) - "link" -> changeReceiverLink = createChangeReceiver(events) + "text" -> changeReceiverText = createChangeReceiver(events) } } override fun onCancel(arguments: Any?) { when (arguments) { "image" -> changeReceiverImage = null - "link" -> changeReceiverLink = null + "text" -> changeReceiverText = null } } @@ -53,7 +53,7 @@ class ReceiveSharingIntentPlugin(val registrar: Registrar) : companion object { private val MESSAGES_CHANNEL = "receive_sharing_intent/messages" private val EVENTS_CHANNEL_IMAGE = "receive_sharing_intent/events-image" - private val EVENTS_CHANNEL_LINK = "receive_sharing_intent/events-link" + private val EVENTS_CHANNEL_TEXT = "receive_sharing_intent/events-text" @JvmStatic fun registerWith(registrar: Registrar) { @@ -70,8 +70,8 @@ class ReceiveSharingIntentPlugin(val registrar: Registrar) : val eChannelImage = EventChannel(registrar.messenger(), EVENTS_CHANNEL_IMAGE) eChannelImage.setStreamHandler(instance) - val eChannelLink = EventChannel(registrar.messenger(), EVENTS_CHANNEL_LINK) - eChannelLink.setStreamHandler(instance) + val eChannelText = EventChannel(registrar.messenger(), EVENTS_CHANNEL_TEXT) + eChannelText.setStreamHandler(instance) registrar.addNewIntentListener(instance) } @@ -81,7 +81,7 @@ class ReceiveSharingIntentPlugin(val registrar: Registrar) : override fun onMethodCall(call: MethodCall, result: Result) { when { call.method == "getInitialIntentData" -> result.success(initialIntentData) - call.method == "getInitialLink" -> result.success(initialLink) + call.method == "getInitialText" -> result.success(initialText) else -> result.notImplemented() } } @@ -90,7 +90,7 @@ class ReceiveSharingIntentPlugin(val registrar: Registrar) : when { intent.type?.startsWith("image") == true && (intent.action == Intent.ACTION_SEND - || intent.action == Intent.ACTION_SEND_MULTIPLE) -> { + || intent.action == Intent.ACTION_SEND_MULTIPLE) -> { // Sharing images val value = getImageUris(intent) if (initial) initialIntentData = value @@ -98,12 +98,17 @@ class ReceiveSharingIntentPlugin(val registrar: Registrar) : changeReceiverImage?.onReceive(context, intent) } (intent.type == null || intent.type?.startsWith("text") == true) - && (intent.action == Intent.ACTION_SEND - || intent.action == Intent.ACTION_VIEW) -> { + && intent.action == Intent.ACTION_SEND -> { // Sharing text + val value = intent.getStringExtra(Intent.EXTRA_TEXT) + if (initial) initialText = value + latestText = value + changeReceiverText?.onReceive(context, intent) + } + intent.action == Intent.ACTION_VIEW -> { // Opening URL val value = intent.dataString - if (initial) initialLink = value - latestLink = value - changeReceiverLink?.onReceive(context, intent) + if (initial) initialText = value + latestText = value + changeReceiverText?.onReceive(context, intent) } } } @@ -134,8 +139,8 @@ class ReceiveSharingIntentPlugin(val registrar: Registrar) : && (intent.action == Intent.ACTION_SEND || intent.action == Intent.ACTION_SEND_MULTIPLE) -> getImageUris(intent) (intent?.type == null || intent.type?.startsWith("text") == true) - && (intent?.action == Intent.ACTION_SEND - || intent?.action == Intent.ACTION_VIEW) -> intent.dataString + && intent?.action == Intent.ACTION_SEND -> intent.getStringExtra(Intent.EXTRA_TEXT) + intent?.action == Intent.ACTION_VIEW -> intent.dataString else -> null } diff --git a/example/README.md b/example/README.md index 1af0aef5..b4e0144a 100644 --- a/example/README.md +++ b/example/README.md @@ -21,7 +21,26 @@ android/app/src/main/manifest.xml android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize"> + + + + + + + + + + + + + + + + @@ -83,6 +102,13 @@ ios/Share Extension/info.plist NSExtensionActivationRule + + NSExtensionActivationSupportsText + + + NSExtensionActivationSupportsWebURLWithMaxCount + 1 + NSExtensionActivationSupportsImageWithMaxCount 100 @@ -95,9 +121,21 @@ ios/Share Extension/info.plist .... ``` -ios/Share Extension/ShareViewContriller.swift -```swift +ios/Runner/Runner.entitlements +```xml +.... + + com.apple.developer.associated-domains + + applinks:example.com + +.... +``` + + +ios/Share Extension/ShareViewController.swift +```swift import UIKit import Social import MobileCoreServices @@ -105,8 +143,11 @@ import Photos class ShareViewController: SLComposeServiceViewController { - let sharedKey = "ImageSharePhotoKey" - var imagesData: [String] = [] + let sharedKey = "ShareKey" + var sharedData: [String] = [] + let imageContentType = kUTTypeImage as String + let textContentType = kUTTypeText as String + let urlContentType = kUTTypeURL as String override func isContentValid() -> Bool { return true @@ -116,65 +157,128 @@ class ShareViewController: SLComposeServiceViewController { // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments. if let content = extensionContext!.inputItems[0] as? NSExtensionItem { - let contentType = kUTTypeImage as String - if let contents = content.attachments { for (index, attachment) in (contents as! [NSItemProvider]).enumerated() { - if attachment.hasItemConformingToTypeIdentifier(contentType) { - attachment.loadItem(forTypeIdentifier: contentType, options: nil) { [weak self] data, error in - - if error == nil, let url = data as? URL, let this = self { - - for component in url.path.components(separatedBy: "/") where component.contains("IMG_") { - - // photo: /var/mobile/Media/DCIM/101APPLE/IMG_1320.PNG - // edited photo: /var/mobile/Media/PhotoData/Mutations/DCIM/101APPLE/IMG_1309/Adjustments/FullSizeRender.jpg - - // cut file's suffix if have, get file name like IMG_1309. - let fileName = component.components(separatedBy: ".").first! - if let asset = this.imageAssetDictionary[fileName] { - this.imagesData.append( asset.localIdentifier) - } - break - } - - // If this is the last item, save imagesData in userDefaults and redirect to host app - if index == (content.attachments?.count)! - 1 { - // TODO: IMPROTANT: This should be your host app bundle identiefier - let hostAppBundleIdentiefier = "com.kasem.sharing" - let userDefaults = UserDefaults(suiteName: "group.\(hostAppBundleIdentiefier)") - userDefaults?.set(this.imagesData, forKey: this.sharedKey) - userDefaults?.synchronize() - this.redirectToHostApp() - this.extensionContext!.completeRequest(returningItems: [], completionHandler: nil) - } - - } else { - print("GETTING ERROR") - let alert = UIAlertController(title: "Error", message: "Error loading image", preferredStyle: .alert) - - let action = UIAlertAction(title: "Error", style: .cancel) { _ in - self?.dismiss(animated: true, completion: nil) - } - - alert.addAction(action) - self?.present(alert, animated: true, completion: nil) - self?.extensionContext!.completeRequest(returningItems: [], completionHandler: nil) - } - } + + if attachment.hasItemConformingToTypeIdentifier(imageContentType) { + handleImages(content: content, attachment: attachment, index: index) + } else if attachment.hasItemConformingToTypeIdentifier(textContentType) { + handleText(content: content, attachment: attachment, index: index) + } else if attachment.hasItemConformingToTypeIdentifier(urlContentType) { + handleUrl(content: content, attachment: attachment, index: index) } } } } } + override func didSelectPost() { + print("didSelectPost"); + } + override func configurationItems() -> [Any]! { // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here. return [] } - private func redirectToHostApp() { - let url = URL(string: "SharePhotos://dataUrl=\(sharedKey)") + private func handleText (content: NSExtensionItem, attachment: NSItemProvider, index: Int) { + attachment.loadItem(forTypeIdentifier: textContentType, options: nil) { [weak self] data, error in + + if error == nil, let item = data as? String, let this = self { + + this.sharedData.append( item) + + // If this is the last item, save imagesData in userDefaults and redirect to host app + if index == (content.attachments?.count)! - 1 { + // TODO: IMPROTANT: This should be your host app bundle identiefier + let hostAppBundleIdentiefier = "com.kasem.sharing" + let userDefaults = UserDefaults(suiteName: "group.\(hostAppBundleIdentiefier)") + userDefaults?.set(this.sharedData, forKey: this.sharedKey) + userDefaults?.synchronize() + this.redirectToHostApp(type: .text) + this.extensionContext!.completeRequest(returningItems: [], completionHandler: nil) + } + + } else { + self?.dismissWithError() + } + } + } + + private func handleUrl (content: NSExtensionItem, attachment: NSItemProvider, index: Int) { + attachment.loadItem(forTypeIdentifier: urlContentType, options: nil) { [weak self] data, error in + + if error == nil, let item = data as? URL, let this = self { + + this.sharedData.append(item.absoluteString) + + // If this is the last item, save imagesData in userDefaults and redirect to host app + if index == (content.attachments?.count)! - 1 { + // TODO: IMPROTANT: This should be your host app bundle identiefier + let hostAppBundleIdentiefier = "com.kasem.sharing" + let userDefaults = UserDefaults(suiteName: "group.\(hostAppBundleIdentiefier)") + userDefaults?.set(this.sharedData, forKey: this.sharedKey) + userDefaults?.synchronize() + this.redirectToHostApp(type: .text) + this.extensionContext!.completeRequest(returningItems: [], completionHandler: nil) + } + + } else { + self?.dismissWithError() + } + } + } + + private func handleImages (content: NSExtensionItem, attachment: NSItemProvider, index: Int){ + attachment.loadItem(forTypeIdentifier: imageContentType, options: nil) { [weak self] data, error in + + if error == nil, let url = data as? URL, let this = self { + + for component in url.path.components(separatedBy: "/") where component.contains("IMG_") { + + // photo: /var/mobile/Media/DCIM/101APPLE/IMG_1320.PNG + // edited photo: /var/mobile/Media/PhotoData/Mutations/DCIM/101APPLE/IMG_1309/Adjustments/FullSizeRender.jpg + + // cut file's suffix if have, get file name like IMG_1309. + let fileName = component.components(separatedBy: ".").first! + if let asset = this.imageAssetDictionary[fileName] { + this.sharedData.append( asset.localIdentifier) + } + break + } + + // If this is the last item, save imagesData in userDefaults and redirect to host app + if index == (content.attachments?.count)! - 1 { + // TODO: IMPROTANT: This should be your host app bundle identiefier + let hostAppBundleIdentiefier = "com.kasem.sharing" + let userDefaults = UserDefaults(suiteName: "group.\(hostAppBundleIdentiefier)") + userDefaults?.set(this.sharedData, forKey: this.sharedKey) + userDefaults?.synchronize() + this.redirectToHostApp(type: .image) + this.extensionContext!.completeRequest(returningItems: [], completionHandler: nil) + } + + } else { + self?.dismissWithError() + } + } + } + + private func dismissWithError(){ + print("GETTING ERROR") + let alert = UIAlertController(title: "Error", message: "Error loading image", preferredStyle: .alert) + + let action = UIAlertAction(title: "Error", style: .cancel) { _ in + self.dismiss(animated: true, completion: nil) + } + + alert.addAction(action) + present(alert, animated: true, completion: nil) + extensionContext!.completeRequest(returningItems: [], completionHandler: nil) + } + + private func redirectToHostApp(type: RedirectType) { + let url = URL(string: "SharePhotos://dataUrl=\(sharedKey)#\(type)") var responder = self as UIResponder? let selectorOpenURL = sel_registerName("openURL:") @@ -186,6 +290,11 @@ class ShareViewController: SLComposeServiceViewController { } } + enum RedirectType { + case image + case text + } + /// Key is the matched asset's original file name without suffix. E.g. IMG_193 private lazy var imageAssetDictionary: [String : PHAsset] = { @@ -216,7 +325,7 @@ class ShareViewController: SLComposeServiceViewController { #### 4. Compiling issues and their fixes * Error: App does not build after adding Share Extension? -* Fix: Check Build Settings of your share extension and remove everything that tries to import Cocoapods from your main project. i.e. under `Linking/Other Linker Flags` +* Fix: Check Build Settings of your share extension and remove everything that tries to import Cocoapods from your main project. i.e. remove everything under `Linking/Other Linker Flags` * You might need to disable bitcode for the extension target @@ -243,7 +352,8 @@ class MyApp extends StatefulWidget { class _MyAppState extends State { StreamSubscription _intentDataStreamSubscription; - List _sharedFiles; + List _sharedFiles; + String _sharedText; @override void initState() { @@ -251,16 +361,36 @@ class _MyAppState extends State { // For sharing images coming from outside the app while the app is in the memory _intentDataStreamSubscription = - ReceiveSharingIntent.getIntentDataStreamAsUri().listen( - (List uris) { - _sharedFiles = uris; + ReceiveSharingIntent.getIntentDataStream().listen((List value) { + setState(() { + _sharedFiles = value; + }); }, onError: (err) { - print("Latest Intent Data error: $err"); + print("getIntentDataStream error: $err"); }); // For sharing images coming from outside the app while the app is closed - ReceiveSharingIntent.getInitialIntentDataAsUri().then((List uris) { - _sharedFiles = uris; + ReceiveSharingIntent.getInitialIntentData().then((List value) { + setState(() { + _sharedFiles = value; + }); + }); + + // For sharing or opening urls/text coming from outside the app while the app is in the memory + _intentDataStreamSubscription = + ReceiveSharingIntent.getTextStream().listen((String value) { + setState(() { + _sharedText = value; + }); + }, onError: (err) { + print("getLinkStream error: $err"); + }); + + // For sharing or opening urls/text coming from outside the app while the app is closed + ReceiveSharingIntent.getInitialText().then((String value) { + setState(() { + _sharedText = value; + }); }); } @@ -272,13 +402,22 @@ class _MyAppState extends State { @override Widget build(BuildContext context) { + const textStyleBold = const TextStyle(fontWeight: FontWeight.bold); return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Plugin example app'), ), body: Center( - child: Text('Number of shared files: ${_sharedFiles?.length ?? 0}'), + child: Column( + children: [ + Text("Shared files:", style: textStyleBold), + Text(_sharedFiles?.join(",") ?? ""), + SizedBox(height: 100), + Text("Shared urls/text:", style: textStyleBold), + Text(_sharedText ?? "") + ], + ), ), ), ); diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 24edf62b..58ebc0a5 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -14,7 +14,7 @@ android:icon="@mipmap/ic_launcher"> development com.apple.developer.associated-domains - applinks:getpool.io + applinks:example.com com.apple.security.application-groups diff --git a/example/ios/Sharing Extension/ShareViewController.swift b/example/ios/Sharing Extension/ShareViewController.swift index 7545bfc0..014939fd 100644 --- a/example/ios/Sharing Extension/ShareViewController.swift +++ b/example/ios/Sharing Extension/ShareViewController.swift @@ -13,10 +13,11 @@ import Photos class ShareViewController: SLComposeServiceViewController { - let sharedKey = "ImageSharePhotoKey" + let sharedKey = "ShareKey" var sharedData: [String] = [] let imageContentType = kUTTypeImage as String - let textContentType = kUTTypePropertyList as String + let textContentType = kUTTypeText as String + let urlContentType = kUTTypeURL as String override func isContentValid() -> Bool { return true @@ -33,6 +34,8 @@ class ShareViewController: SLComposeServiceViewController { handleImages(content: content, attachment: attachment, index: index) } else if attachment.hasItemConformingToTypeIdentifier(textContentType) { handleText(content: content, attachment: attachment, index: index) + } else if attachment.hasItemConformingToTypeIdentifier(urlContentType) { + handleUrl(content: content, attachment: attachment, index: index) } } } @@ -72,6 +75,30 @@ class ShareViewController: SLComposeServiceViewController { } } + private func handleUrl (content: NSExtensionItem, attachment: NSItemProvider, index: Int) { + attachment.loadItem(forTypeIdentifier: urlContentType, options: nil) { [weak self] data, error in + + if error == nil, let item = data as? URL, let this = self { + + this.sharedData.append(item.absoluteString) + + // If this is the last item, save imagesData in userDefaults and redirect to host app + if index == (content.attachments?.count)! - 1 { + // TODO: IMPROTANT: This should be your host app bundle identiefier + let hostAppBundleIdentiefier = "com.kasem.sharing" + let userDefaults = UserDefaults(suiteName: "group.\(hostAppBundleIdentiefier)") + userDefaults?.set(this.sharedData, forKey: this.sharedKey) + userDefaults?.synchronize() + this.redirectToHostApp(type: .text) + this.extensionContext!.completeRequest(returningItems: [], completionHandler: nil) + } + + } else { + self?.dismissWithError() + } + } + } + private func handleImages (content: NSExtensionItem, attachment: NSItemProvider, index: Int){ attachment.loadItem(forTypeIdentifier: imageContentType, options: nil) { [weak self] data, error in diff --git a/example/lib/main.dart b/example/lib/main.dart index 3411ad23..a8328a16 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -26,7 +26,7 @@ class _MyAppState extends State { _sharedFiles = value; }); }, onError: (err) { - print("Latest Intent Data error: $err"); + print("getIntentDataStream error: $err"); }); // For sharing images coming from outside the app while the app is closed @@ -38,16 +38,16 @@ class _MyAppState extends State { // For sharing or opening urls/text coming from outside the app while the app is in the memory _intentDataStreamSubscription = - ReceiveSharingIntent.getLinkStream().listen((String value) { + ReceiveSharingIntent.getTextStream().listen((String value) { setState(() { _sharedText = value; }); }, onError: (err) { - print("Latest Intent Data error: $err"); + print("getLinkStream error: $err"); }); // For sharing or opening urls/text coming from outside the app while the app is closed - ReceiveSharingIntent.getInitialLink().then((String value) { + ReceiveSharingIntent.getInitialText().then((String value) { setState(() { _sharedText = value; }); diff --git a/ios/Classes/SwiftReceiveSharingIntentPlugin.swift b/ios/Classes/SwiftReceiveSharingIntentPlugin.swift index 34865f64..b02b080f 100644 --- a/ios/Classes/SwiftReceiveSharingIntentPlugin.swift +++ b/ios/Classes/SwiftReceiveSharingIntentPlugin.swift @@ -5,7 +5,7 @@ public class SwiftReceiveSharingIntentPlugin: NSObject, FlutterPlugin, FlutterSt static let kMessagesChannel = "receive_sharing_intent/messages"; static let kEventsChannelImage = "receive_sharing_intent/events-image"; - static let kEventsChannelLink = "receive_sharing_intent/events-link"; + static let kEventsChannelLink = "receive_sharing_intent/events-text"; private var initialIntentData: [String]? = nil private var latestIntentData: [String]? = nil @@ -36,7 +36,7 @@ public class SwiftReceiveSharingIntentPlugin: NSObject, FlutterPlugin, FlutterSt if(call.method == "getInitialIntentData") { result(self.initialIntentData); - } else if(call.method == "getInitialLink") { + } else if(call.method == "getInitialText") { result(self.initialLink); } else { result(FlutterMethodNotImplemented); @@ -86,7 +86,7 @@ public class SwiftReceiveSharingIntentPlugin: NSObject, FlutterPlugin, FlutterSt if(setInitialData) { initialLink = latestLink } - _eventSinkImage?(latestLink) + _eventSinkLink?(latestLink) } } else { latestLink = url.absoluteString @@ -107,7 +107,7 @@ public class SwiftReceiveSharingIntentPlugin: NSObject, FlutterPlugin, FlutterSt public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? { if (arguments as! String? == "image") { _eventSinkImage = events; - } else if (arguments as! String? == "link") { + } else if (arguments as! String? == "text") { _eventSinkLink = events; } else { return FlutterError.init(code: "NO_SUCH_ARGUMENT", message: "No such argument\(String(describing: arguments))", details: nil); @@ -118,7 +118,7 @@ public class SwiftReceiveSharingIntentPlugin: NSObject, FlutterPlugin, FlutterSt public func onCancel(withArguments arguments: Any?) -> FlutterError? { if (arguments as! String? == "image") { _eventSinkImage = nil; - } else if (arguments as! String? == "link") { + } else if (arguments as! String? == "text") { _eventSinkLink = nil; } else { return FlutterError.init(code: "NO_SUCH_ARGUMENT", message: "No such argument as \(String(describing: arguments))", details: nil); diff --git a/lib/receive_sharing_intent.dart b/lib/receive_sharing_intent.dart index 9af9e1b9..e5f8fb26 100644 --- a/lib/receive_sharing_intent.dart +++ b/lib/receive_sharing_intent.dart @@ -9,7 +9,7 @@ class ReceiveSharingIntent { static const EventChannel _eChannelImage = const EventChannel( "receive_sharing_intent/events-image"); static const EventChannel _eChannelLink = const EventChannel( - "receive_sharing_intent/events-link"); + "receive_sharing_intent/events-text"); static Stream> _streamImage; static Stream _streamLink; @@ -28,8 +28,8 @@ class ReceiveSharingIntent { /// /// * the initially stored link (possibly null), on successful invocation; /// * a [PlatformException], if the invocation failed in the platform plugin. - static Future getInitialLink() async { - return await _mChannel.invokeMethod('getInitialLink'); + static Future getInitialText() async { + return await _mChannel.invokeMethod('getInitialText'); } /// A convenience method that returns the initially stored image uri @@ -48,8 +48,8 @@ class ReceiveSharingIntent { /// /// If the link is not valid as a URI or URI reference, /// a [FormatException] is thrown. - static Future getInitialLinkAsUri() async { - final String data = await getInitialLink(); + static Future getInitialTextAsUri() async { + final String data = await getInitialText(); if (data == null) return null; return Uri.parse(data); } @@ -105,11 +105,11 @@ class ReceiveSharingIntent { /// only when stream listener count changes from 1 to 0. /// /// If the app was stared by a link intent or user activity the stream will - /// not emit that initial one - query either the `getInitialLink` instead. - static Stream getLinkStream() { + /// not emit that initial one - query either the `getInitialText` instead. + static Stream getTextStream() { if (_streamLink == null) { _streamLink = _eChannelLink - .receiveBroadcastStream("link") + .receiveBroadcastStream("text") .cast(); } return _streamLink; @@ -146,9 +146,9 @@ class ReceiveSharingIntent { /// Refer to `getLinkStream` about error/exception details. /// /// If the app was started by a share intent or user activity the stream will - /// not emit that initial uri - query either the `getInitialLinkAsUri` instead. + /// not emit that initial uri - query either the `getInitialTextAsUri` instead. static Stream getLinkStreamAsUri() { - return getLinkStream().transform( + return getTextStream().transform( new StreamTransformer.fromHandlers( handleData: (String data, EventSink sink) { if (data == null) {