capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

feat: add Android autocomplete support

Open liamdebeasi opened this issue 2 years ago • 15 comments

Feature Request

Description

Autocomplete is not working in Ionic apps with Capacitor (see: https://github.com/ionic-team/ionic-framework/issues/23695). After investigating with the Chromium team in https://bugs.chromium.org/p/chromium/issues/detail?id=1238338, it looks like autocomplete support was removed from the Android webview in favor of developers implementing Android autofill (https://developer.android.com/guide/topics/text/autofill) in their apps.

It would be great if Capacitor could add support for Android autofill otherwise users will not be able to autofill emails, credit cards, etc in Capacitor apps.

Platform(s)

Android

Preferred Solution

The preferred solution is for Capacitor to implement Android autofill.

Alternatives

The alternative is to leave this up to developers to implement on a per-application basis.

liamdebeasi avatar Sep 14 '21 14:09 liamdebeasi

Is there any information on this topic !?

f1ght4fun avatar Nov 11 '21 14:11 f1ght4fun

Very intrigued on how this feature would look like. For our use case, not having Password Managers working on native Capacitor apps is a bit of a PITA.

Odonno avatar Jan 04 '22 16:01 Odonno

Is this feature planned? I would also be very interested in this topic, as we would also like to use the Android Autofill Framework in one of our projects.

msadcenko avatar Jan 05 '22 11:01 msadcenko

I'm looking for a solution as well, please advise.

btw for iOS we can use this plugin: https://github.com/cuongpl/capacitor-ios-autofill-save-password

it pops up the ‘save password’ dialog.

We need something similar for android.

holygekko avatar Jan 16 '22 20:01 holygekko

Any news related to this feature?

telpat0298 avatar Mar 07 '22 12:03 telpat0298

@liamdebeasi any news?

msadcenko avatar Mar 07 '22 12:03 msadcenko

I do not work on the Capacitor team, so I do not have any updates regarding this Capacitor feature. Someone from the Capacitor team will update this thread when they have any news to share.

liamdebeasi avatar Mar 07 '22 13:03 liamdebeasi

Still no news?

telpat0298 avatar Jul 14 '22 13:07 telpat0298

Any good news on this issue ?

sujeetulli avatar Jul 18 '22 11:07 sujeetulli

Need help on this.

KalyaniVenna81 avatar Jul 18 '22 11:07 KalyaniVenna81

Please help on this issue

viharshitha avatar Jul 18 '22 11:07 viharshitha

Any update?

shanselm-ergon avatar Aug 10 '22 08:08 shanselm-ergon

Sorry for the lack of updates here, I lead Ionic's Native Engineering teams and I am digging in. More soon.

giralte-ionic avatar Aug 10 '22 17:08 giralte-ionic

This is getting a deeper investigation, updates as they are available.

giralte-ionic avatar Aug 22 '22 14:08 giralte-ionic

Any updates on this?, this is an absolutely required feature for all apps, If there are any workarounds for this please let me know

really-Deep avatar Sep 06 '22 03:09 really-Deep

Any good news on this issue? Does any one know any workarounds?

Artkoch avatar Nov 09 '22 08:11 Artkoch

liamdebeasi

Did you manage to find a workaround for this issue?

Artkoch avatar Nov 09 '22 09:11 Artkoch

liamdebeasi

Did you manage to find a workaround for this issue?

Use capacitor in app browser package On your mobile app login screen open capacitor browser window with your website's login page and carry on login & registration there, complete whole process in the browser only and upto the end when auth is either successful or failed, in case of success copy the auth token generated to clipboard and close the window make sure to listen to event of window closing from your mobile app's login page once this event of window closing is fired check the contents of your clipboard, if there's a valid auth token inside that it worked, otherwise report as login/register failed. This solution works perfectly just make sure to clear the clipboard at the end :) The credentials popup appears perfectly in the in-app browser tab have fun!

really-Deep avatar Nov 09 '22 14:11 really-Deep

this whole thing is not even ionic's problem, android removed credentials autofill feature inside webviews, and the whole ionic app is inside a webview, that's why it's not working, but my above workaround gets things done

really-Deep avatar Nov 09 '22 14:11 really-Deep

liamdebeasi

Did you manage to find a workaround for this issue?

We implemented it with java in the android project according to the google documentation (https://developer.android.com/guide/topics/text/autofill-services)

msadcenko avatar Nov 09 '22 14:11 msadcenko

liamdebeasi

Did you manage to find a workaround for this issue?

We implemented it with java in the android project according to the google documentation (https://developer.android.com/guide/topics/text/autofill-services)

i did try that but for some reasons couldn't get it working can you please share the code? it would be great help

really-Deep avatar Nov 09 '22 15:11 really-Deep

liamdebeasi

Did you manage to find a workaround for this issue?

We implemented it with java in the android project according to the google documentation (https://developer.android.com/guide/topics/text/autofill-services)

Very interesting. Could you share snippets of your code? As far as I understand you would have to write a capacitor plugin in order to call java methods from within the app.

Artkoch avatar Nov 10 '22 13:11 Artkoch

Hello there

I don't see the problem in Android or the autofill services. Autofill works fine in a normal WebView, the problem occurs only, if the web app is bundled in a capacitor app.

I created two projects to demonstrate the problem.

https://github.com/shanselm-ergon/autofill-android-webview-demo This is a simple Android app, which shows an HTML file in a WebView. If an autofill service is configured in the Android settings, this form is automatically filled with the information provided by the service (see the README.md in the repo for reproduction).

https://github.com/shanselm-ergon/autofill-capacitor-demo This is a simple Capacitor app, which does basically the same as the example above. The embedded web app is the same as above. If you start to fill the form, no autofill suggestions are given (see the README.md in the repo for reproduction).

If the autofill debug options are turned on on the device, a difference in the log outputs can be noted. I don't no why, but the service won't return any autofill data.

In our case, it is not an option to create our own autofill service, we don't want to build up a new data base, we want to use an existing one.

Any help would be appreciated, this would really be a nice feature.

shanselm-ergon avatar Jan 24 '23 14:01 shanselm-ergon

Hello @giralte-ionic , any news on this topic?

shanselm-ergon avatar Feb 22 '23 07:02 shanselm-ergon

Right now we are folding this into our work on Capacitor 5 given the scope of the fix. We're still finalizing what Capacitor 5 will include and am aiming for a Q2 release.

giralte-ionic avatar Feb 22 '23 13:02 giralte-ionic

I can confirm that autocomplete doesn't work on Android 8 and newer, still works on Android 5.1-7. Nothing we can do about it since Google has removed it from the WebView.

On Android 8+, autocomplete has been replaced with autofill, but autofill requires a secure context to work. So, for making autofill work on Android 8+, the apps have to use https and a custom domain, it won't work from http://localhost, which is the default url used by Capacitor apps, won't work from https://localhost neither as it's not considering localhost secure despite it's using https.

We have updated the Capacitor autofill docs to reflect that information. https://capacitorjs.com/docs/guides/autofill-credentials

For doing that, the app developers have to add this to their Capacitor config file:

"server": {
    "androidScheme": "https",
    "hostname": "my-app.com" // this is an example, use your own hostname value
}

Note that changing the scheme and/or hostname will cause web data loss since the web data is tied to the url (localStorage, IndexedDB, etc.)

What giralte-ionic has mentioned about this being included in Capacitor 5 means that new Capacitor 5 apps will use https by default, no other change will be made in Capacitor 5 as what is need is a configuration change on the user apps to be served form a "secure context".

jcesarmobile avatar Feb 23 '23 17:02 jcesarmobile

We have updated the Capacitor autofill docs to reflect that information. https://capacitorjs.com/docs/guides/autofill-credentials

For doing that, the app developers have to add this to their Capacitor config file:

"server": {
    "androidScheme": "https",
    "hostname": "my-app.com" // this is an example, use your own hostname value
}

I can confirm that the "androidScheme": "https" entry in Capacitor config file solves the issue. I wrongly thought that the android:scheme in AndroidManifest.xml was enough.

abennouna avatar Feb 23 '23 18:02 abennouna

Thank you for your explanations, I can also confirm, that the suggested settings fix autofill on android.

@jcesarmobile about the change to https as default for the Android scheme, how about iOS? Currently https can not be set as iosScheme, as described in the docs: https://capacitorjs.com/docs/config . Will this behaviour also change in Capacitor 5, or is only the Android default affected?

shanselm-ergon avatar Mar 23 '23 12:03 shanselm-ergon

Please, don't ping me.

Using https is not possible on iOS since the WKWebView reserves http/https and some others.

Apple considers custom schemes secure, if some web API doesn't consider custom schemes such as capacitor:// secure you can report it to Apple and they usually fix it.

jcesarmobile avatar Mar 23 '23 12:03 jcesarmobile

Thanks for clarification.

shanselm-ergon avatar Mar 23 '23 13:03 shanselm-ergon