dpa99c / phonegap-launch-navigator

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

IOS Uncaught "options.start.join" is not a function #172

Closed raymondtri closed 6 years ago

raymondtri commented 6 years ago

This error only happens with IOS which is strange, here is the code I am calling to activate launchnavigator: launchNativeMaps(lat, lng){ let options: LaunchNavigatorOptions = {}; this.launchNavigator.navigate([lat, lng], options); }

I then receive the error: Error: Uncaught (in promise): TypeError: options.start.join is not a function. (In 'options.start.join(",")', 'options.start.join' is undefined) navigate@file:///var/containers/Bundle/Application/7B16B597-B5AF-4F57-B7CB-FDB6E75B7CD4/Socialite.app/www/plugins/uk.c...

Any thoughts?

dpa99c commented 6 years ago

That error looks to be raised by this line of code.

The start parameter is expected to be either an address string, a lat/lon string in the format "lat,lon" or an array in the format [lat,lon].

The only way I can see that error being raised is if an object (rather than an array) was passed as the start argument, since the above condition if(typeof(options.start) === "object") would evaluate to true but join() is not a member function of type object, only of type array.

For example, this would cause that error:

launchnavigator.navigate(destination, {
    start: {}
});

There should probably be some better type checking on the inputs to throw a more meaningful error if the wrong type is passed in as an argument.

raymondtri commented 6 years ago

I'll get you a more detailed explanation here a bit later today, thanks for the quick reply!

raymondtri commented 6 years ago

I am not passing a start parameter, just the LaunchNavigatorOptions = {};

  1. Is a start argument required?
  2. What is the default type of the start parameter in LaunchNavigatorOptions? I am just passing an empty array.
dpa99c commented 6 years ago

@raymondtri

Is a start argument required?

No.

What is the default type of the start parameter in LaunchNavigatorOptions? I am just passing an empty array.

LaunchNavigatorOptions is part of the Ionic Native Typescript wrapper around this plugin and as such is not under direct control of this plugin. From the looks of their code the default type is string | number[]. However, it may be that the compiled JS is wrongly passing an empty object rather than array when start is not defined. The easiest way to check would be to connect Safari Web Inspector to the webview and debug it by placing some breakpoints.