amplify-flutter icon indicating copy to clipboard operation
amplify-flutter copied to clipboard

Generic AuthException is thrown when the device does not have chrome installed

Open PawlikMichal25 opened this issue 4 years ago • 6 comments

Describe the bug The plugin uses CustomTabsManagerActivity which won't be available if Chrome is uninstalled on a device.

To Reproduce Steps to reproduce the behavior:

  1. Uninstall Chrome, you can do it on any Pixel device
  2. Try calling signInWithWebUI()
  3. ~~App will crash, happens every time~~ A generic AuthException is thrown

Expected behavior ~~At least nothing should happen instead of crash, but special error for this would be better.~~ A more specific exception should be thrown

Platform [X] Android

Stacktrace

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {MYPACKAGENAME/com.amazonaws.mobileconnectors.cognitoauth.activities.CustomTabsManagerActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=MYURL/... pkg=com.android.chrome (has extras) }
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3785)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3817)
       at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6680)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

PawlikMichal25 avatar May 19 '21 08:05 PawlikMichal25

@BaranMichal25 Do you have a particular Android browser you would try to target instead of chrome? We are looking into introducing a parameter to specify a browser on Android.

Unfortunately I don't know if it's possible for us to prospectively check on whether Chrome is available because - as of API level 30 - this involves a change to the app's manaifest file (please correct me if that sounds wrong!), although you could certainly use the method provided at this link. It might also be possible for us to introduce an API to check for this using dart (you would need to make the manifest change, but wouldn't need to worry about custom Android implementation).

In any case, we are looking into adding support for specifying a browser.

haverchuck avatar May 19 '21 21:05 haverchuck

Theoretically, I'm not sure whether we can expect users to have any browser installed. I would firstly try returning special error in this case.

Please correct me if I'm wrong, but I think that plugin could add code you linked somewhere in this method: https://github.com/aws-amplify/amplify-flutter/blob/05dcbb9a689f05557ac1629125e95d445ed0cca7/packages/amplify_auth_cognito/android/src/main/kotlin/com/amazonaws/amplify/amplify_auth_cognito/AuthCognito.kt#L400

Regarding the AndroidManifest change, can't it be added here? https://github.com/aws-amplify/amplify-flutter/blob/c773828dd91ded62e25eece9b8945f07fa551957/packages/amplify_auth_cognito/android/src/main/AndroidManifest.xml#L2 Or we could inform plugin users that they should add it to their manifest for plugin to work?

PawlikMichal25 avatar May 20 '21 07:05 PawlikMichal25

Is there any update on this issue? Many of our users are experiencing crashes on Samsung phones since Chrome isn't installed by default. Also the docs don't seem to make any mention of Chrome being a requirement so this seems like a fairly large issue.

dander11 avatar Oct 18 '21 16:10 dander11

any update on this?

Sunsiha avatar Nov 27 '21 03:11 Sunsiha

I believe there were some changes in Amplify-Android (which Amplify-Flutter depends on when targeting Android) to resolve this. I just tested this on a Pixel 4 with Chrome disabled with Amplify-Flutter 0.4.5. I do not see the app crash. I see a generic AuthException.

As the original issue suggested, a more specific Exception would be better. I am going to update the issue title to reflect that.

Jordan-Nelson avatar May 10 '22 19:05 Jordan-Nelson

Hello - We have recently released a new developer preview version of the Auth category (amplify_flutter v1.0.0-next.0). This new version is a full re-write of the auth category in dart, and it supports Mobile, Desktop, and Web. This issue is addressed in this new version. You will now see a UrlLauncherException if the user has no supported browsers installed.

You can read more about the developer preview release in the blog post and docs. I will update this issue again once this new version is out of developer preview.

Let me know if you have any questions!

Jordan-Nelson avatar Aug 02 '22 20:08 Jordan-Nelson

This issue has been addressed in v1.0.0 of Amplify Flutter, which is now stable. This release also includes web and desktop support for Auth, API, Analytics, and Storage. You can see the list of new features and bug fixes in the release notes, and see more details on how to migrate in the upgrade guide.

Jordan-Nelson avatar Apr 17 '23 18:04 Jordan-Nelson