dpa99c / phonegap-launch-navigator

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

The navigate function is not working every time on iOS #235

Closed vlinde closed 4 years ago

vlinde commented 4 years ago

Bug report

Current behavior: Sometimes the function call (navigate) is not opening the navigator map.

Expected behavior: The button must work every time.

Steps to reproduce: The button (the function call) is working as expected for a while but if I open a navigation app, I do some things and when I come back to my app, the launch button is not working anymore. Sometimes I can open the navigation app for many times but after my app runs in the background for a little bit longer, the button will not work as expected. My app is not crashed or something like that, it will work as expected, only the launch button is not responding.

Environment information

iOS build issue:

Related code:

let promptsOptions: PromptsOptions = {
  headerText: "Auswahl merken ?",
  bodyText: "Die gleiche App für die nächste Navigation benutzen?",
  yesButtonText: "Ja",
  noButtonText: "Nein"
};

let rememberChoiceOptions: RememberChoiceOptions = {
  prompt: promptsOptions
};

let appSelectionOptions: AppSelectionOptions = {
  dialogHeaderText: "App wählen",
  cancelButtonText: "Abbrechen",
  rememberChoice: rememberChoiceOptions
};

let launchNavigatorOptions: LaunchNavigatorOptions = {
  appSelection: appSelectionOptions
};

this.launchNavigator.navigate(this.project.city + ' ' + this.project.street + ' ' + this.project.zip,
  launchNavigatorOptions).catch((e) => {
// error handle
});

I checked the project vars and they are ok every time. Console output

launchNavigatorOptions output when is working launchNavigatorOptions output when is not working

Other information: I tried to set the launchNavigatorOptions var when I press the button or when I open the page. On both cases I have the same issue. I checked the logs from xCode, the function is triggered, I can see some messages (my phone doesn't have all navigation apps installed. I get these messages in all cases, when it's working or not) but I can't see any error.

dpa99c commented 4 years ago

The issue you describe is likely specific to your project and not a bug with this plugin: this plugin provides a simple way to invoke the custom URL schemes installed on a device, therefore there is little code that can cause such a problem.

When you say "the launch button is not working anymore", it could be that an error in your app UI is causing the invocation of the plugin to fail. I suggest placing a breakpoint on the call to the navigate() function in the your app code using Safari Web Inspector so you can debug it when the button is pressed.

Als please build and run an app from the example project to see if you can reproduce the issue to rule out other causes within your own app project.

vlinde commented 4 years ago

I tried the example project and is working as expected.

On my app, when the preferred app is not selected from the options, the navigate function will use common.APP.USER_SELECT as value. Then the navigator app from the select list should be selected. The app will be locked when the function getItem is called with param choice. In the debugger the last called function is ensureStore from

var getItem = function(key, callback){
    ensureStore();
    return store.getItem(key, function(err, value){
        callback(value);
    });
};

The execution is stopped because the return is not reached and the callback is not executed. I think the issue is related to the local storage.

dpa99c commented 4 years ago

Thanks for taking time to investigate. I will close this for now as it looks like you've found the problem and it's not related to this plugin.