我有一个用AngularJS 1.5.3,Cordova和Ionic v1编写的应用程序。
我正在使用这两个插件来实现一些SSO(单点登录)功能。
https://github.com/EddyVerbruggen/Custom-URL-scheme
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/
ionic info
Ionic:
ionic (Ionic CLI) : 4.10.3 (C:\Users\User\node_modules\ionic)
Ionic Framework : ionic1 1.3.5
@ionic/v1-toolkit : 1.0.22
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 8.1.0, ios 6.1.0, browser 5.0.4, windows 4.4.3
Cordova Plugins : cordova-plugin-ionic-webview 4.1.3, (and 17 other plugins)
System:
Android SDK Tools : 26.1.1 (C:\Users\User\Documents\Android\sdk)
NodeJS : v10.21.0 (C:\Program Files\nodejs\node.exe)
npm : 6.14.4
OS : Windows 10
config.xml
<plugin name="cordova-plugin-inappbrowser" spec="^4.0.0">
<variable name="usewkwebview" value="true" />
</plugin>
<plugin name="cordova-plugin-customurlscheme" spec="https://github.com/EddyVerbruggen/Custom-URL-scheme.git">
<variable name="URL_SCHEME" value="selfserviceapp" />
<variable name="ANDROID_SCHEME" value=" " />
<variable name="ANDROID_HOST" value=" " />
<variable name="ANDROID_PATHPREFIX" value="/" />
</plugin>
As I'm using cordova-ios 6.1.0 I'm using WkWebView only.
<platform name="ios">
<preference name="WKWebViewOnly" value="true" />
package.json
"dependencies": {
"cordova-android": "^8.1.0",
"cordova-ios": "^6.1.0",
"cordova-android-support-gradle-release": "^3.0.1",
"cordova-plugin-camera": "^4.1.0",
"cordova-plugin-compat": "^1.2.0",
"cordova-plugin-customurlscheme": "git+https://github.com/EddyVerbruggen/Custom-URL-scheme.git",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-geolocation": "^4.0.2",
"cordova-plugin-inappbrowser": "^4.0.0",
"cordova-plugin-network-information": "^2.0.2",
"cordova-plugin-safariviewcontroller": "^1.6.0",
"cordova-plugin-save-image": "^0.3.0",
"cordova-plugin-settings-hook": "^0.2.7",
"cordova-plugin-splashscreen": "^5.0.4",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-whitelist": "^1.3.4",
"cordova.plugins.diagnostic": "^4.0.12",
"ionic-plugin-keyboard": "^2.2.1",
"natives": "^1.1.6"
},
"plugins": {
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-compat": {},
"cordova-plugin-device": {},
"cordova-plugin-settings-hook": {},
"cordova-plugin-save-image": {},
"cordova-plugin-file": {},
"cordova-plugin-network-information": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-safariviewcontroller": {},
"cordova-plugin-camera": {},
"cordova-plugin-geolocation": {},
"cordova.plugins.diagnostic": {
"ANDROID_SUPPORT_VERSION": "28.+"
},
"cordova-android-support-gradle-release": {
"ANDROID_SUPPORT_VERSION": "27.+"
},
"cordova-plugin-customurlscheme": {
"URL_SCHEME": "selfserviceapp",
"ANDROID_SCHEME": " ",
"ANDROID_HOST": " ",
"ANDROID_PATHPREFIX": "/"
},
"cordova-plugin-inappbrowser": {
"usewkwebview": "true"
}
}
该应用程序将在浏览器中打开身份提供程序,用户将在该浏览器中登录,然后将用户重定向到该应用程序。
它在Android上运行良好,但对于iOS,它不会重定向回应用程序。
它停留在浏览器页面上,用户必须手动单击“完成”按钮以重定向回应用程序。
*-Info.plist
代码段:
在窗口对象上
var handleOpenURL = null;
window['handleOpenURL'] = function (url) {
if (handleOpenURL) {
handleOpenURL(url);
}
};
self.openUrl = function (url) {
return new Promise(function (resolve, reject) {
try {
SafariViewController.isAvailable(function (available) {
if (available) {
self.hideSpinner();
handleOpenURL = function (url) {
if (url.startsWith(ClientConfig.config.redirect_uri)) {
self.processAuthCodeResponse(url)
.then(function (token) {
resolve(token);
})
.catch(function(error) {
reject(error);
})
.finally(function() {
window['SafariViewController'].hide();
});
}
}
SafariViewController.show({
url: url
})
} else {
alert(' Browser Not Available! ');
}
});
}
catch (error) {
reject(error);
}
});
};
答案 0 :(得分:0)
我认为Ionic v1不支持此功能,您可以尝试使用Firebase深层链接将URL重定向回您的应用程序。