IOS在使用回调URI时,需要在URI后加上“://”才能生效。因此,在Auth0应用程序的设置中,正确的回调URI应该是:
ionicApp://your-auth0-domain/cordova/ionic/callback
代码示例:
// auth.js文件中的授权配置,设置回调URI
const auth0Config = {
domain: 'your-auth0-domain',
clientId: 'your-client-ID',
audience: 'your-audience',
redirectUri: Platform.OS === 'ios' ?
'ionicApp://your-auth0-domain/cordova/ionic/callback://':
'ionicApp://your-auth0-domain/cordova/ionic/callback',
responseType: 'code',
scope: 'openid profile email',
accessType: 'offline'
};
在Xcode中,需要在Info.plist文件中添加以下配置:
CFBundleURLTypes
CFBundleURLName
com.auth0
CFBundleURLSchemes
ionicApp
LSApplicationQueriesSchemes
ionicApp