Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add browser proxy #199

Merged
merged 1 commit into from Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugin.xml
Expand Up @@ -70,6 +70,11 @@
</config-file>
<source-file src="src/android/IonicCordovaCommon.java" target-dir="src/com/ionicframework/common"/>
</platform>
<platform name="browser">
<js-module src="src/browser/IonicCordovaCommon.js" name="IonicCordovaCommon">
<runs />
</js-module>
</platform>
<dependency id="cordova-plugin-splashscreen" version="^5.0.1"/>
<dependency id="cordova-plugin-ionic-webview" version="^2.1.4"/>
<dependency id="cordova-plugin-file" version="^6.0.1"/>
Expand Down
28 changes: 28 additions & 0 deletions src/browser/IonicCordovaCommon.js
@@ -0,0 +1,28 @@
function notSupported(win,fail) {
console.log('IonicCordova is not supported on browser platform');
setTimeout(function(){
if (win) {
win();
}
},0);
}

function getPreferences(win,fail) {
setTimeout(function(){
win({
minBackgroundDuration: 30,
disabled: true
});
},0);
}

module.exports = {
getPreferences: getPreferences,
getAppInfo: notSupported,
setPreferences:notSupported,
configure: notSupported
};

require("cordova/exec/proxy").add("IonicCordovaCommon", module.exports);


9 changes: 6 additions & 3 deletions www/common.ts
Expand Up @@ -682,9 +682,12 @@ class IonicDeploy implements IDeployPluginAPI {
return new Promise<ISavedPreferences>(async (resolve, reject) => {
try {
channel.onNativeReady.subscribe(async () => {
cordova.exec(async (prefs: ISavedPreferences) => {
resolve(prefs);
}, reject, 'IonicCordovaCommon', 'getPreferences');
// timeout to let browser proxy to init
window.setTimeout(function () {
cordova.exec(async (prefs: ISavedPreferences) => {
resolve(prefs);
}, reject, 'IonicCordovaCommon', 'getPreferences');
}, 0);
});
} catch (e) {
channel.onIonicProReady.fire();
Expand Down