Closed pke closed 7 years ago
Native pickers usually have a 2-state toggle such as checkbox to indicate if the user wishes to remember the selection. This plugin (currently) uses cordova-plugin-actionsheet to display the list of available apps. And since actionsheet itself uses native UI elements, I don't see any easy way to add a checkbox to that UI without either forking the actionsheet plugin or swapping it out for a different UI widget. So it doesn't look like something I can add easily/quickly.
In the meantime, the plugin API is sufficient that you could create your own UI which incorporate a "remember" checkbox and persistently store the user choice (e.g. in local storage).
And there is no way to display the native picker like the social sharing plugin does?
I didn't say there's no way to do it: there's probably another UI element that Actionsheet can be swapped out for. But it's not trivial and I don't have much time right now.
I do have an idea, @dpa99c. While this will not specifically cover @pke's request, you can return the app used in the success callback, and then @pke can save it in his app, and going forward, specify that app as the default.
Also, pke could create a settings view within his app where the end user can select or change their default navigation app using methods you've already provided us, regardless of the above implementation.
+1 for @jvjvjv idea. Please return selected app in the success callback.
I just wonder: When I use a mailto
protocol link Android displays a "choose once" or "choose always" for the mail app. Is that a standard system dialog or not? I know in Windows Phone there is such dialog (at least it was until the hideous Windows 10).
Otherwise I'd be happy with the solution @jvjvjv was suggesting.
Yes, it's a system dialog which is hard-coded in the operating system for specific protocols. For example, mailto:
and, more relevantly, geo:
protocol. Making a URL call to the system browser using one of these protocols, it is intercepted by the operating system. On Android, this triggers the picker dialog which includes the "choose once" or "choose always" behaviour. However, these are a limited number of hard-coded protocols that the OS invokes special behaviour for. The default behaviour of this plugin (if an app is not specified) is to present a list of available apps to the user. However, the native system dialog behaviour for these specific protocols cannot be leveraged for this purpose: we have no means of defining a new special protocol which will be intercepted and understood if opened in the system browser.
@jvjvjv has made good compromise solution and I'll implement it when a get some time.
@dpa99c I see. I tried the geo
protocol before. Unfortunately not all navapps register themselves for this protocol. So even when I have gmaps installed on iOS it will still always launch Apple maps.
That's why I even considered using this plugin. Usually I go with system protocols to launch apps.
Just published v3.2.1 to npm. Using that version, you should be able to specify appSelectionCallback
option which will be passed the app that was selected by the user in the native picker.
@pke Happy with the appSelectionCallback
solution? Can this be closed?
Yes, I'll see what I can do with it
FYI v4 of the plugin (just published) now supports a mechanism to remember which app was selected. By default, it uses cordova-plugin-dialogs to ask the user whether to remember the selected app on the first time they are shown the available list of apps. However, this behaviour can be customised with a custom UI using promptFn
option: see the updated docs for details.
Native app pickers usually have an option to launch the app only once or always use the same app from now on. Would it be difficult to add such feature?