llfbandit / app_links

Android App Links, Deep Links, iOs Universal Links and Custom URL schemes handler for Flutter.
https://pub.dev/packages/app_links
Apache License 2.0
220 stars 81 forks source link

Uri with parameters #132

Closed loneObserver1 closed 5 months ago

loneObserver1 commented 5 months ago

Describe the bug

I have setup my applinks listener. All works but if i add parameters on my uri only first parameter is get.

void initDeepLinks() {
    debugPrint('###############');
    debugPrint('Init Deep Links');
    debugPrint('###############');
    // Subscribe to all events (initial link and further)
    _appLinks.uriLinkStream.listen((uri) {
      if (uri.hasAuthority && uri.queryParametersAll.isNotEmpty) {
        Map<String, String> queryParameters = {};
        final data = uri.queryParametersAll.entries.first;
        /*for (final elem in data) {
          final parts = elem.split('=');
          queryParameters[parts[0]] = parts[1];
        }*/
        //Detect app links
        if (queryParameters.containsKey('action') &&
            queryParameters.containsKey('type') &&
            queryParameters.containsKey('id')) {
          switch (queryParameters['action']) {
            case 'view':
              switch (queryParameters['type']) {
                case 'event':
                  _openEvent(queryParameters['id']!);
                  break;
                case 'user':
                  _openProfile(queryParameters['id']!);
                  break;
              }
              break;
            default:
              break;
          }
        } else {
          throw ('Invalid deeplinks');
        }
      }
    });
  }
adb shell am start -a android.intent.action.VIEW \
  -d "decibell://com.mobile.decibell/?eventId=testEventId&id=testId"

A clear and concise description of what the bug is.

query: eventId=testEventId

When i create my AppLinks i create an Uri like this :

String url = Uri(host: 'com.mobile.decibell', path: '/', scheme: 'decibell', queryParameters: {'eventId': 'testEventId', 'id': 'testId'}).toString();

Does it related to

[X] App Links (Android)
[ ] Deep Links (Android)
[ ] Universal Links (iOS)
[ ] or Custom URL schemes? (iOS)

Does the example project work?

[ ] Yes
[X] No
[ ] Irrelevant here

Did you fully read the instructions for the targeted platform before submitting this issue?

Uploaded your files to webserver, HTTPS, direct connection, scheme pattern setup, ...

[ ] Yes
[X] No
[ ] Irrelevant here

brunosp15 commented 5 months ago

To test the deeplink with adb you need to add \ before &. As mentioned here.

So try this: adb shell am start -a android.intent.action.VIEW \ -d "decibell://com.mobile.decibell/?eventId=testEventId\&id=testId"