OpenId Connect 无法在 ios 7/8 (OpenID Connect/React) 上运行
OpenId Connect not working on ios 7/8 (OpenID Connect/React)
我在我的 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.[=14= 开始正常运行]
是什么导致了这个问题,我怎样才能让它在 iOS 7/8 时起作用?
提前致谢。
我在阅读了一些文档后解决了这个问题。
OIDC 库使用 babel-polyfill 添加对旧 Web 浏览器的支持。
根据 polyfill 文档,iOS 支持的最低版本是 9。
参考- Minimum supported version for polyfill
这就是为什么该应用在 iOS 9 及更高版本上 运行 完美,而在 iOS 7 和 iOS 8 上显示空白屏幕。
我在我的 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.[=14= 开始正常运行]
是什么导致了这个问题,我怎样才能让它在 iOS 7/8 时起作用?
提前致谢。
我在阅读了一些文档后解决了这个问题。
OIDC 库使用 babel-polyfill 添加对旧 Web 浏览器的支持。
根据 polyfill 文档,iOS 支持的最低版本是 9。
参考- Minimum supported version for polyfill
这就是为什么该应用在 iOS 9 及更高版本上 运行 完美,而在 iOS 7 和 iOS 8 上显示空白屏幕。