uni_links icon indicating copy to clipboard operation
uni_links copied to clipboard

A few questions about Custom URL Scheme.

Open kimmy-wang opened this issue 3 years ago • 7 comments

I entered myScheme://user? in the Safari browser, and after pressing Enter, my application switched from the background to the foreground.

I have a few questions:

  1. how to get the url I just entered in the application?
  2. Is the url obtained by the following code? If so, why can't I get the url in my application.
/// Handle incoming links - the ones that the app will recieve from the OS
  /// while already started.
  void _handleIncomingLinks() {
    if (!kIsWeb) {
      // It will handle app links while the app is already started - be it in
      // the foreground or in the background.
      _sub = uriLinkStream.listen((Uri? uri) {
        if (!mounted) return;
        print('got uri: $uri');
        setState(() {
          _latestUri = uri;
          _err = null;
        });
      }, onError: (Object err) {
        if (!mounted) return;
        print('got err: $err');
        setState(() {
          _latestUri = null;
          if (err is FormatException) {
            _err = err;
          } else {
            _err = null;
          }
        });
      });
    }
  }

Smartphone (please complete the following information):

  • Device: iOS Simulator
  • OS: ios 14.5

kimmy-wang avatar May 05 '21 12:05 kimmy-wang

Did you declare myScheme scheme in ios/Runner/Info.plist?

avioli avatar May 06 '21 12:05 avioli

<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>CFBundleURLName</key>
			<string>user</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>myScheme</string>
			</array>
		</dict>
	</array>

kimmy-wang avatar May 06 '21 12:05 kimmy-wang

I had the same problem

wbbbbbbbbbbbbbbbbbb avatar May 26 '21 08:05 wbbbbbbbbbbbbbbbbbb

@avioli I'm using [https and custom schemes] and am testing on my [iPhone xs max], which is running [iOS14.8].

Using a custom URL scheme, after waking up the application from the background, the uri information cannot be obtained. Using the https scheme, after waking up the application from the background, the uri information can be obtained.

Is there any progress on this issue?

kimmy-wang avatar Sep 20 '21 00:09 kimmy-wang

Any updates?

kimmy-wang avatar Sep 21 '21 14:09 kimmy-wang

@avioli

kimmy-wang avatar Oct 25 '21 14:10 kimmy-wang

I'm having the same issue, but on Android.

I've declared my custom scheme in AndroidManifest.xml, app is opened fine when clicking on an universal link with my custom scheme, but it just doesn't handle it in release mode for some reason.

Any help would be helpful. Thanks!

Ivaskuu avatar Oct 27 '21 00:10 Ivaskuu