【问题标题】:How to get flutter + iOS + flutter_appauth + end session to stop crashing?如何让flutter + iOS + flutter_appauth + end session 停止崩溃?
【发布时间】:2022-09-30 04:37:22
【问题描述】:

尝试使用flutter_appauth并尝试让它在iOS上注销,但似乎无论我尝试了什么,它都会崩溃。

这是我们的注销代码示例:

      var esr = EndSessionRequest(
          idTokenHint: idToken,
          issuer: \'<ommitted from sample>\',
          postLogoutRedirectUrl: \'com.myapp.myapp://login-callback\',
          allowInsecureConnections: false,
          preferEphemeralSession: true,
          serviceConfiguration: <auth endpoint, token endpoint, end session...>,
      );
      await appAuth.endSession(esr);

同样,对于登录:

      final AuthorizationTokenResponse? result =
      await appAuth.authorizeAndExchangeCode(
        AuthorizationTokenRequest(
          <client id>,
          \'com.myapp.myapp://login-callback\',
          serviceConfiguration: <service config>,
          scopes: [...scopes...],
          preferEphemeralSession: true,
          allowInsecureConnections: false,
        ),
      );

我们在日志中看到了这一点:

2022-09-21 10:47:16.063321-0400 Runner[59528:8189105] [Presentation] Attempt to present <SFAuthenticationViewController: 0x1064d5600> on <SFAuthenticationViewController: 0x106424800> (from <SFAuthenticationViewController: 0x106424800>) whose view is not in the window hierarchy.
2022-09-21 10:48:01.594067-0400 Runner[59528:8189105] No windows have a root view controller, cannot save application state

在 iOS/runner 下,我们的 plist 中有这个:

        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>com.myapp.myapp</string>
         </array>
        <key>LSRequiresIPhoneOS</key>
        <true/>

这似乎在android上运行得很好。 iOS 还需要什么特别的东西吗?

    标签: ios flutter oauth keycloak


    【解决方案1】:

    您需要将以下内容添加到您的 Info.plist 文件中:

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>com.myapp.myapp</string>
            </array>
        </dict>
    </array> 
    

    解释,字典键是区分大小写的,所以 CFBundleURLSchemes 和 CFBundleURLschemes 是不一样的。前者是 URL 方案数组的键,后者是 URL 方案本身的键。

    【讨论】:

      猜你喜欢
      • 2017-07-05
      • 1970-01-01
      • 1970-01-01
      • 2020-02-15
      • 2021-05-26
      • 2020-01-21
      • 2020-01-29
      • 2018-02-01
      • 1970-01-01
      相关资源
      最近更新 更多