MaikuB / flutter_appauth

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

[flutter_appauth] Feature: Android pendingOperation callback #496

Open mdikcinar opened 1 month ago

mdikcinar commented 1 month ago

As i mentioned here android has a lifecycle issue. In this pr i tried to solved it simply by adding HAS_PENDING_OPERATION invoke method for this situation.

I think it can be solved clearly with adding a callback method maybe but i didn't want to touch the code base too much and just focused to solve it simply.

In the app side i just did this quickly and solve the problem

 final MethodChannel methodChannel = const MethodChannel('crossingthestreams.io/flutter_appauth');

  @override
  void initState() {
    super.initState();
    methodChannel.setMethodCallHandler((methodCall) async {
      if (methodCall.method == 'hasPendingOperation') {
        final arguments = methodCall.arguments;
        if (arguments case {'accessToken': String _}) {
          unawaited(context.read<AuthenticationCubit>().login());
        }
      }
    });
  }