EddyVerbruggen / nativescript-directions

:point_up_2: :point_right: :point_down: :point_left: Open the Maps app to show directions to anywhere you like
MIT License
83 stars 21 forks source link

preferGoogleMaps is not working #25

Open chrisalexqm opened 5 years ago

chrisalexqm commented 5 years ago

I set preferGoogleMaps: true, in iOS options but it doesnt open Google Maps App (Google Maps is installed) instead it opens iOS Maps App.

Maybe I am wrong, help me please :D

PD: Only when I set an array in to: it opens Google Maps with way points (I think this is because open the web url)

EddyVerbruggen commented 5 years ago

Hmm, that's strange, because the demo app in this repo does open Google Maps with that preference passed in. Can you confirm that?

git clone https://github.com/EddyVerbruggen/nativescript-directions
cd nativescript-directions/src
npm run demo.ios.device

Then hit the 'from address to coord' button (last button).

If that works, then what you can try in your project:

chrisalexqm commented 5 years ago

@EddyVerbruggen Hello and thanks for answering :D

I couldnt replicate demo app because I am working in Windows with NativeScript SideKick but I could run this issue in the NS Playground: https://play.nativescript.org/?template=play-vue&id=L4M2rY

As you can see I set preferGoogleMaps as true. Hope you can replicate this issue.

EddyVerbruggen commented 5 years ago

Ha, you're running the app inside the Playground app, which doesn't have nativescript-directions installed. I saw you added it yourself (good thinking!), but the only piece missing is the plist entry that allows the app to query the OS whether or not the Google Maps app is installed:

https://github.com/EddyVerbruggen/nativescript-directions/blob/1e4aec8e3034956705cb370d4a1eacc3eac8e457/src/platforms/ios/Info.plist#L5-L8

Since it can't determine that without this plist entry, it falls back to Apple Maps. The waypoint overrides that behavior, but that's a different issue really.

So I think your code is correct, and once you run it as a standalone app it'll probably work just fine.

chrisalexqm commented 5 years ago

Ohhh well, I added comgooglemaps to my Info.plist and it still opening Maps from iOS. I can use directly the functions inside plugin but I want to contribute to the community by solving this issue and improving the plugin 😸 . I will try removing platform/ios folder and I'll tell you.

Thanks for your time!

EddyVerbruggen commented 5 years ago

THANK YOU! I'd be happy to merge any code/doc you want to PR.

chrisalexqm commented 5 years ago

I test with fb:// appAvailability and it is returning false, the same with comgooglemaps://. I have installed both of those applications. I added this to my Info.plist

comgooglemaps fb twitter

I am doing something bad?

EddyVerbruggen commented 5 years ago

That’s hard to tell without the actual code. Can you share a minimal repo?

chrisalexqm commented 5 years ago

I uploaded this https://github.com/chrisalexqm/directionstest tell me if you can run it

EddyVerbruggen commented 5 years ago

@chrisalexqm Runs fine. I didn't have Google Maps on my iPad so it opened Apple Maps. Then I installed the Google Maps apps and this prompt was shown (as expected):

IMG_0100

In Dutch: "Directions wants to open Google Maps. [Cancel / Open]"

After accepting this (one-time) prompt it opened Google Maps. So all is working fine with your app for me.

chrisalexqm commented 5 years ago

Well, definitely I don't know what is happening... Uhmm could be the way how SideKick build the app 🤔