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
176 stars 68 forks source link

Universal link with query param not handled by the plugin when triggered with NFC. #77

Closed qwadrox closed 9 months ago

qwadrox commented 9 months ago

Describe the bug

We have an NFC tag with the following data: https://example.com/mobile-nfc?id=21123134. When tapped, our app opens, but the plugin doesn't seem to handle it.

After updating AppDelegate.swift with specific code (shown below), we can extract the id param and URL, assuming our configuration is correct.

override func application(
          _ application: UIApplication,
          continue userActivity: NSUserActivity,
          restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
      ) -> Bool {

          guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
                let incomingURL = userActivity.webpageURL,
                let components = NSURLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else {
              return false
          }

          guard let params = components.queryItems else {
              return false
          }

          if let idValue = params.first(where: { $0.name == "id" })?.value {
              //I could print the id param 
              print("ID is \(idValue)")
              return true
          } else {
              print("ID is missing")
              return false
          }
      }

Could you guide us on how to achieve such a feature with app_links or clarify if a custom solution is necessary? Thank you for your time!

Configuration:

  1. On the server this has been added to apple-app-site-association file:
    "applinks": {
    "apps": [],
    "details": [
      {
        "appIDs": ["SKAHKHDAS.com.example.app"],
        "paths": [
          "/mobile-nfc"
        ]
      }
    ]
    }
  2. Signing & Capabilities > + Capability > Associated Domains Add an entry: applinks:[example.com]

Does it related to

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

Does the example project work?

[ ] Yes
[ ] 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
[ ] No
[ ] Irrelevant here

llfbandit commented 9 months ago

Overriding application methods directly conflicts with the plugin.

I suggest you to read this https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application#discussion and this https://github.com/llfbandit/app_links/issues/47

qwadrox commented 9 months ago

Thank you! Cocorico