MaikuB / flutter_appauth

A Flutter wrapper for AppAuth iOS and Android SDKs
274 stars 246 forks source link

Android: authorizeAndExchangeCode is not returns any response #495

Open mdikcinar opened 6 months ago

mdikcinar commented 6 months ago

Hi, i have an issue on some android phones not all of them. I did some debugging and the issue is when i call authorizeAndExchangeCode it opens a browser activity with mainActivity.startActivityForResult but at the same time also onDetachedFromEngine is working. So when i come back from browser activity, onAttachedToEngine is working and in onActivityResult pendingOperation becomes null and returns false therefore i can't authenticate the user. But if i call authorizeAndExchangeCode second time it returns success directly without open a browser activity and user logins the app successfully.

Happens on Android api 34, api 30. But i have tried with another phone works on api 34 it worked well without this issue. Currently using flutter_appauth: 6.0.4

Is there any idea how can i solve the problem?

mdikcinar commented 6 months ago

https://github.com/MaikuB/flutter_appauth/pull/496

MaikuB commented 4 months ago

Whilst you have a PR on this, I don't see steps on how to properly reproduce. Furthermore, what you mentioned around onDetachedFromEngine being called sounds odd as it would mean entire Flutter engine is destroyed. This is typically something that happens more when the app has been killed or the Flutter activity hosting the app has been killed (e.g. if you forced the device only have one activity). What you say has implications for other plugins, including official ones from Google. The plugin is following a similar the Google sign in plugin too. As such as I'm inclined to think the root cause hasn't been identified