MaikuB / flutter_appauth

A Flutter wrapper for AppAuth iOS and Android SDKs
269 stars 238 forks source link

[flutter_appauth] Catch native ActivityNotFoundException #465

Closed NikHomann closed 5 months ago

NikHomann commented 6 months ago

Currently, if there are no browser installed on the device, the underlying plugin AppAuth-Android will throw an ActivityNotFoundException which crashes the Flutter application. This was for instance reported here: https://github.com/MaikuB/flutter_appauth/issues/168

You can reproduce the error by running the example app on any emulator without any installed browsers (disable the default Chrome in Settings - Apps - Chrome) and trying to login.

This fixes the error by catching the ActivityNotFoundException and returning a PlattformException.

MaikuB commented 5 months ago

Thanks for the PR. Will see how it goes once I reproduce this but initial thought from looking at the change is that the change involves catch any exception as oppose to ActivityNotFoundException that you mentioned. If the only cause of an ActivityNotFoundException is to do with a lack of browser then I would say it would better to catch that specific exception and translate this to provide more details that the API call failed due to a lack of a browser