tschoffelen / react-native-map-link

🗺 Open the map app of the user's choice.
MIT License
653 stars 141 forks source link

Android 11 / SDK 30 support #177

Closed arabold closed 3 years ago

arabold commented 3 years ago

It took me a while to figure this out, but when switching to Android 11/Android SDK 30 (i.e. using Expo SDK 41), this library doesn't work out of the box anymore. The reason is the new Package Visibilty security feature. We'll have to update our AndroidManifest.xml to explicitly allow querying for other apps.

I'm posting my changes here as it might help others running into the same problem. It would also be great to get some feedback as I'm not able to test all these apps myself. Eventually, once we have confirmed this works as expected, this should probably go in the react-native-map-link documentation.

<manifest package="com.example.app">
  <queries>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="http"/>
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="https"/>
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="geo" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="google.navigation" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="applemaps" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="citymapper" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="uber" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="lyft" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="transit" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="truckmap" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="waze" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="yandexnavi" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="moovit" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="yandexmaps://maps.yandex." />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="yandextaxi" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="kakaomap" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="mapycz" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="mapsme" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="osmand.geo" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="gett" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="nmap" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="dgis" />
    </intent>
  </queries>
  ...
</manifest>

So far I could verify the following apps: google-maps, citymapper, uber, lyft, waze, maps-me

tschoffelen commented 3 years ago

Ah amazing! Was trying to figure out something similar for a related library, but wasn't able to test it myself yet.

tschoffelen commented 3 years ago

Feel free to open a PR to add this to the README if you have time. It might not be perfect yet, but it's better than not having anything at all.

Also, if you're going to do that, could I point out Github allows using the amazing <details> HTML tag in Markdown?

<details><summary>My title here</summary>

A bunch of hidden... well, details.

</details>

Might be a good way to list the instructions for both iOS and Android, without making the README super long.

tschoffelen commented 3 years ago

I've now added this to the README of the library, and have confirmed this works as expected.

Thanks again @arabold!

DwCleb commented 3 years ago

@tschoffelen an important point to mentioned at docs: https://stackoverflow.com/questions/62969917/how-to-fix-unexpected-element-queries-found-in-manifest-error

tschoffelen commented 3 years ago

Good point, I've added some details:

https://github.com/flexible-agency/react-native-map-link/commit/6faf0f4b08f031e1dad7efd4f5d7a81e478f3c31

Thanks!

wromthrax commented 3 years ago

I guess this cannot be used in managed Expo app then (no access to AndroidManifest)?

tschoffelen commented 3 years ago

I don't think Expo has a way to deal with Android 11 Package Visibility yet as far as I can tell...

arcollector commented 2 years ago

I am having this same problme, openInbox does nothing, i added to the manisfer

    <queries>
      <intent>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="mailto"/>
      </intent>
    </queries>

but nothing happen

tschoffelen commented 2 years ago

@arcollector - I think you might be talking about another library?

arcollector commented 2 years ago

@tschoffelen yep i am very sorry

amserhii11 commented 1 year ago

I've added query statement to AndroidManifest but I still getting reject from Google Play Team.

We found that your app is not compliant with how [QUERY_ALL_PACKAGES permission] is allowed to be used.

React Native 0.68.2 react-native-map-link 2.9.3