[solved] canOpenURL issues on Android (both Expo & Standalone)


#1

Hey everyone,

  • SDK 25
  • Nexus 5x (standalone)
  • Genymotion Simulator (Expo)
  • works correctly on iOS (both canOpenURL and openURL)

What I’m trying to accomplish:

  • check if app is installed
  • open app

Despite the app being on the phone, Android will return false. I have tried with this with OTHER apps as well. Android says false.

I’m assuming canOpenURL is the culprit not openURL.

Any help would be appreciated!

Thanks!


#2

Hi @peterpme - we’ll need some more specific information in order to help you with this issue. What URL are you trying to pass into canOpenURL? Could you provide a snack that minimally reproduces this issue?


#3

Hey @esamelson,

Sorry for the delay. Here you go:

https://snack.expo.io/rkfIb-vFM

Try this on both iOS and Android.

on iOS:

  • canOpenURL returns false despite Gmail being installed (this part is less concerning, I don’t think its a standalone issue)
  • opens Gmail app

on Android:

  • canOpenURL returns false despite Gmail being installed.
  • Does NOT open Gmail app

Ideally, I would like to know (on both iOS and Android) which mail app is installed and display them to the user.

Are the intent URIs different on Android? Is that the issue?

Thanks!!


#4

The reason iOS returns false is because the googlegmail scheme isn’t whitelisted in the Expo client. Some apps used to probe for well-known URL schemes to figure out what you have installed on your phone, which was too much of a privacy issue under Apple’s judgement.

Reading this link: https://stackoverflow.com/questions/3470042/intent-uri-to-launch-gmail-app – it looks like Gmail on Android doesn’t have a URL scheme.


#5

Thanks @ide!

I didn’t realize realize Android had a different flow for opening mail.


closed #6

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.