Android API 30 (Android 11) requires an extra permission defined in the app manifest to open other apps (Google Maps in my case). But if the <manifest>
element isn't available in an Ionic/Cordova project how can I get this permission on my project? I have a config.xml
file that lists permissions for Android and iOS but I dont know where to add this permission.
Others have said this API change requires adding a permission in the <manifest>
In my Ionic 5 project I can only edit a config.xml
file that looks like this:
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:networkSecurityConfig="@xml/network_security_config" />
<queries>
<package android:name="com.google.android.apps.maps" />
</queries>
</edit-config>
<resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
<allow-intent href="market:*" />
I've tried adding the suggested <queries>
element but that does not work. I'm clicking an address in the UI and using Ionic Launch Navigator plugin to open Google Maps. It works on Android API 29 but not API 30.
How should I add the permission to open Google Maps in Android?
CodePudding user response:
window.open(URL)
will work on Android 11 to open Google Maps without requiring permission changes or API key. See help article.
The article explains how to build URL
to open google maps in a cross-platform way with support for finding locations and navigation. I didn't have to mess with permissions or AndroidManifest.xml or Cordova element.
In digging I was using the Ionic suggested Launch Navigator
plugin which opens Google Maps a little differently and because of Android 11 permission changes this plugin now requires an Intent permissionthat I could not figure out and gave up for the launch-by-url format.