avioli / uni_links

Flutter plugin for accepting incoming links.
BSD 2-Clause "Simplified" License
563 stars 303 forks source link

A few questions about Custom URL Scheme. #112

Open kimmy-wang opened 3 years ago

kimmy-wang commented 3 years ago

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):

avioli commented 3 years ago

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

kimmy-wang commented 3 years ago
<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>
wbbbbbbbbbbbbbbbbbb commented 3 years ago

I had the same problem

kimmy-wang commented 3 years ago

@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 commented 3 years ago

Any updates?

kimmy-wang commented 2 years ago

@avioli

Ivaskuu commented 2 years ago

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!