nodriver-ai/flutter_azure_b2c

Cannot Load iOS Configuration

Opened this issue · 8 comments

I'm following the latest documents but cannot get past loading the config file to run on an iOS 16.2 simulator. I've placed a file at "ios/Resources/auth_config.json". Then implemented the following code in my main widget:

  @override
  void initState() {
    super.initState();

    // It is possible to register callbacks in order to handle return values
    // from asynchronous calls to the plugin
    AzureB2C.registerCallback(B2COperationSource.INIT, (result) async {
      log('CALLBACK RESULT?: ${result}');
      if (result.reason == B2COperationState.SUCCESS) {
        _configuration = await AzureB2C.getConfiguration();
      }
    });
    log('CALLBACK REGISTERED');

    // Important: Remeber to handle redirect states (if you want to support
    // the web platform with redirect method) and init the AzureB2C plugin
    // before the material app starts.
    _redirectFuture = AzureB2C.handleRedirectFuture().then((_) async { 
      log('INIT START');
      final res = await AzureB2C.init("auth_config");
      log('INITED RES: $res');
      //  _configuration = await AzureB2C.getConfiguration();
      // log('LOADED CONFIG?: $_configuration');
      });
  }

But the INIT callback is never invoked. Furthermore, if I uncomment the last 2 lines in the handleRedirectFuture continuation then the app crashes from a Swift nil reference. So my guess is the loading of the config file simply isn't happening. I've exposed this file as an asset in pubspec.yaml but it doesn't fix anything. Additional info:

  • Flutter: 3.3.10
  • flutter_azure_b2c: 0.0.9

hi @sean915213

Did you manage to resolve your issue?
I'm getting similar issue (android working fine), but iOS not
updated info.plist, updated appDelegate.swift, added key chain (com.microsoft.adalcache) but still no luck.
INIT callback doesn't get triggered even with error message.

@alex-dokienko I did not. I moved on to another SDK I think. But have since moved on to other projects.

hi, i'm just stuck because of the same issue. I'm just wondering if someone succeeded to fix or if this plugin is definitely dead.

@gpelizzo
plugin probably died, but I managed to make it work for my case, so I found iOS require tfp format for urls, so I did a fork, I don't remember all details now, but you can check what I change in my fork branch
https://github.com/alex-dokienko/flutter_azure_b2c

@alex-dokienko
Thanks. Unfortunattly, even with your fork, I'm still not able to trigger ININT callback.

yeah, it requires different configuration inside app registrations side on b2c portal, it's not the same as for android, you need to use tfp url structure + proper redirect urls, sorry won't be able to give more details.Another thing, debuging plugin on xcode side helped me to understand what is wrong.

@alex-dokienko thanks again. I give myself a few more hours and then I give up and back to Firebase. I didn't think it would take so long, even more than for the Apple plugin !

hi, finally I found out ! The config json file was not copy from Resources folder. Adding the file into Xcode Copy Bundle Resources fixed the issue.