【问题标题】:OpenId Connect not working on ios 7/8 (OpenID Connect/React)OpenId Connect 在 ios 7/8 上不起作用(OpenID Connect/React)
【发布时间】:2020-10-23 06:38:21
【问题描述】:

我在我的 React 项目中实现了 OIDC。当我在 ios 7/8 中启动我的应用程序时,我得到一个空白屏幕。 在其他更高版本中它工作正常。

我在 index.tsx 中调用了一个 init() 函数:


    /**
     * Initialize Auth module.
     * @param {Object} config Configuration options.
     * @returns {Promise<User>} A promise with the user data.
     */
    init(config) {

        /* main configuration */
        .
        .
        .
        .

        
        return _run()         // Removing this function call makes the app work fine on iOS 7/8
            .then(() => {
                return _user;
            })
            .catch(error => {
                return _user;
            });
    }

这个_run()函数定义为:

function _run() {
    return _mgr
        .signinRedirectCallback()
        .then(user => {
            // if this is a signin redirect action then set the user info
            Logger.info('signinRedirectCallback: Successful redirect signin.', user);
            return (_user = user);
        })
        .catch(error => {
            // otherwise this is a page reload
            Logger.info('signinRedirectCallback: Page reload.', error);

            // Execute logic to check if the user is still authenticated, it invokes a silent signin call which happens through an iFrame.
            return _mgr
                .signinSilent({ redirect_uri: _config.oidc.silent_redirect_uri })
                .then(user => {
                    // if user is still authenticated then set the user info
                    Logger.info('signinSilent:  Page reload. Successful silent signin.', user);
                    return (_user = user);
                })
                .catch(error => {
                    // otherwise unset user info
                    Logger.info('signinSilent: Page reload.', error);
                    _user = null;
                    return Promise.reject(error);
                });
        })
}

如果我从我的 init() 函数中删除 _run() 函数调用,该应用开始在 iOS 7/8 上正常运行

是什么导致了这个问题,我怎样才能使它适用于 iOS 7/8?

提前致谢。

【问题讨论】:

    标签: javascript ios openid-connect


    【解决方案1】:

    我在查看了一些文档后解决了这个问题。

    OIDC 库使用 babel-polyfill 来添加对旧 Web 浏览器的支持。

    参考-OIDC Documentation

    根据 polyfill 文档,iOS 支持的最低版本是 9。

    参考-Minimum supported version for polyfill

    这就是该应用在 iOS 9 及更高版本上完美运行并在 iOS 7 和 iOS 8 上显示空白屏幕的原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-04
      • 2017-02-09
      • 2018-02-08
      • 2017-04-20
      • 1970-01-01
      • 2019-11-15
      相关资源
      最近更新 更多