avioli / uni_links

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

getLatestLink on Android #26

Closed coreysprague closed 5 years ago

coreysprague commented 5 years ago

I'm using https scheme and am testing on my Android Emulator, which is running Android 9.0.

The getLatestLink method isn't implemented on android: https://github.com/avioli/uni_links/blob/master/android/src/main/java/name/avioli/unilinks/UniLinksPlugin.java#L69

@Override
  public void onMethodCall(MethodCall call, Result result) {
    if (call.method.equals("getInitialLink")) {
      result.success(initialLink);
      // } else if (call.method.equals("getLatestLink")) {
      //   result.success(latestLink);
    } else {
      result.notImplemented();
    }
  }

It appears that this code has been commented out since inception of the file.

Is there a technical reason this cannot be enabled?

avioli commented 5 years ago

Well... it is implemented in Objective-C, but isn't exposed to the dart lib. The [handleMethodCall:result] method has the same code commented-out.

From vague memory - initially I built the lib to have only a getLatestLink method, but it turned out to be the wrong approach. For one - the latest link could change and there was no way of notifying the app with just a method, so I've added the Stream getLinksStream, which gives you the latest link, when it changes. Then the problem was that the stream didn't give you the current one, or rather the initial one, so the getInitialLink came to be.

The code for getting the latest link is commented-out and not removed, since I thought I might need to revert to it, but I believe it can be removed, since the Stream + getInitialLink should cover it in a better way.

Do you have a need for getLatestLink?

coreysprague commented 5 years ago

I was confused.

I wasn't seeing getUriLinksStream() working for Android if an app link was followed while the app was running. I was trying to self-diagnose the issue and somewhere along the lines got my apis mixed up before I wrote this up.

Regardless, I ended up solving my specific use case with another package, so I think it's safe to close this.