Essentials icon indicating copy to clipboard operation
Essentials copied to clipboard

[Bug] Launcher TryOpenAsync returns false, OpenAsync returns true

Open lhughey opened this issue 3 years ago • 3 comments

Description

The TryOpenAsync isn't returning true when appropriate. This is an issue because there is no way to know if app open request fails and the user should be redirected to the app store.

As a result, the following logic cannot be used if(await Launcher.TryOpenAsync(appSchemeUri)) Launcher.OpenAsync(appSchemeUri); else Launcher.OpenBrowser(appStoreFallbackLink);

Steps to Reproduce

  1. Install App1 on Droid (Samsung s10 running Droid 11), set URI scheme in App1 so it can be opened by App2 (which is the app will will be modifying to open App1). Use the scheme format "app1://" when passing to the launcher.

  2. Add the following line in a command or codebehind in App2 var ok = await Launcher.TryOpenAsync(App1URIScheme); //The response of 'ok' is false and App1 doesn't open

  3. Comment out the previous line (in step 2) and replace with the following line in App2

  4. await Launcher.OpenAsync(App1URIScheme); //App1 opens on device

Expected Behavior

Line2 above - should return True and open App1 as OpenAsync opens the app

Actual Behavior

Line2 above - returns False and does not open App1.

Basic Information

  • Version with issue: Xamarin.Essentials v1.70, XF 5.0.0.2291
  • Last known good version: Unknown - new development
  • Platform Target Frameworks:
    • Android: Droid 11
  • Nuget Packages:
  • Affected Devices: Samsung s10 running Droid 11

lhughey avatar Jan 25 '22 15:01 lhughey

I can confirm the issue is present in Xamarin.Essentials v1.7.1 too.

This only seems to affect Android 11, earlier versions behave as expected.

WilkoSki avatar Feb 17 '22 12:02 WilkoSki

Is that more related to the new "queries" attribute required for app targeting api 30 ?

https://medium.com/androiddevelopers/package-visibility-in-android-11-cc857f221cd9

softlion avatar Mar 18 '22 11:03 softlion

Is that more related to the new "queries" attribute required for app targeting api 30 ?

https://medium.com/androiddevelopers/package-visibility-in-android-11-cc857f221cd9

@softlion, if it is to do with the queries attribute, I have

  <queries>
    <package android:name="com.google.android.apps.maps" />
  </queries>

in my manifest but what URI scheme is called with CanOpenAsync (or TryOpenAsync)? I tried comgooglemaps:// as per https://stackoverflow.com/questions/30884292/google-map-direction-using-comgooglemaps but still doesn't work.

catapedamania avatar Nov 21 '22 10:11 catapedamania