dpa99c / phonegap-launch-navigator

Phonegap/Cordova plugin which launches native route navigation apps for Android, iOS and Windows
369 stars 131 forks source link

Waze force closes on iOS when address is not URL-encoded #202

Closed fmsouza closed 6 years ago

fmsouza commented 6 years ago

I'm submitting a ... (check one with "x"):

Bug report

Current behavior:

When I use this plugin to open Waze and navigate to some address string instead of coordinates, the app force closes in IOS environment. Looking at the Waze's documentation for Deeplinks it's possible to see they require the params to be URL-encoded in order to make it work properly.

Expected behavior:

When sending an address string as param to the plugin, while selecting Waze as the corresponding app, it should open the app with the address set for navigation without problems.

Steps to reproduce:

Environment information

Runtime issue

iOS build issue:

If using an [Ionic Native Typescript wrapper]() for this plugin:

Cordova:

cordova (Cordova CLI) : 8.0.0 Cordova Platforms : android 6.4.0, browser 5.0.3, ios 4.5.5

System:

Android SDK Tools : 26.1.1 ios-deploy : 1.9.2 ios-sim : 6.1.2 NodeJS : v9.11.1 (/Users/fred/.nvm/versions/node/v9.11.1/bin/node) npm : 6.2.0 OS : macOS High Sierra Xcode : Xcode 9.4.1 Build version 9F2000

Environment:

ANDROID_HOME : /Users/fred/Library/Android/sdk


- Installed Ionic Native modules and versions

├── @ionic-native/app-preferences@4.6.0 ├── @ionic-native/background-fetch@4.9.1 ├── @ionic-native/background-geolocation@4.9.2 ├── @ionic-native/badge@4.10.0 ├── @ionic-native/broadcaster@4.6.0 ├── @ionic-native/core@4.6.0 ├── @ionic-native/deeplinks@4.6.0 ├── @ionic-native/diagnostic@4.6.0 ├── @ionic-native/geolocation@4.6.0 ├── @ionic-native/google-analytics@4.10.0 ├── @ionic-native/http@4.6.0 ├── @ionic-native/launch-navigator@4.6.0 ├── @ionic-native/local-notifications@4.11.0 ├── @ionic-native/network@4.6.0 ├── @ionic-native/splash-screen@4.6.0 ├── @ionic-native/status-bar@4.6.0



**Other information:**

The following address works if you call the plugin to open `Google Maps` and `Apple Maps` is both Android and iOS. When calling in `Waze`, it only works on Android, and crashes in iOS.

Address: _NAPA, 116 West 15th Street, Panama City, Florida, 32401, United States_

A potential fix would be sanitizing the URL before completing the Deeplink call. Javascript has functions for that: `encodeURI` and `encodeURIComponent`.

[Waze Deeplink API documentation](https://developers.google.com/waze/deeplinks/) (Look for _Search_ and _Combining parameters_)

<!--
A POLITE REMINDER

- This is free, open-source software. 
- Although the author makes every effort to maintain it, no guarantees are made as to the quality or reliability, and reported issues will be addressed if and when the author has time. 
- Help/support will not be given by the author, so forums (e.g. Ionic) or Stack Overflow should be used. Any issues requesting help/support will be closed immediately.
- If you have urgent need of a bug fix/feature, the author can be engaged for PAID contract work to do so: please contact dave@workingedge.co.uk
- Rude or abusive comments/issues will not be tolerated, nor will opening multiple issues if those previously closed are deemed unsuitable. Any of the above will result in you being BANNED from ALL of my Github repositories.
-->
dpa99c commented 6 years ago

This plugin's iOS implementation of the Waze URL scheme uses only latitude/longitude coordinate pairs because up until recently Waze did not support combining of the search (q=) and navigation (navigate=yes) parameters.

Therefore the plugin uses its own internal geocoding method to translate the requested address into coordinates. On testing the address you have specified, this seems to work fine with the plugin and Waze on iOS:

2018-08-28 12:52:09.996187+0100 Launch Navigator Simple Example[411:63759] LaunchNavigator[native]: Called navigate() with args: destination=NAPA, 116 West 15th Street, Panama City, Florida, 32401, United States; destType=name; destName=<null>; start=; startType=none; startName=<null>; appName=waze; transportMode=driving; extras=<null>
2018-08-28 12:52:09.996320+0100 Launch Navigator Simple Example[411:63759] LaunchNavigator[native]: Attempting to geocode address: NAPA, 116 West 15th Street, Panama City, Florida, 32401, United States
2018-08-28 12:52:10.108027+0100 Launch Navigator Simple Example[411:63759] LaunchNavigator[native]: Geocoded address 'NAPA, 116 West 15th Street, Panama City, Florida, 32401, United States' to coord '30.1756, -85.662'
2018-08-28 12:52:10.118902+0100 Launch Navigator Simple Example[411:63759] LaunchNavigator[native]: Using waze to navigate to NAPA, 116 West 15th Street, Panama City, Florida, 32401, United States [30.1756, -85.662] from current location
2018-08-28 12:52:10.119133+0100 Launch Navigator Simple Example[411:63759] LaunchNavigator[native]: Launching URI: waze://?ll=30.175552,-85.661968&navigate=yes

Closing as described issue cannot be reproduced.