You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/09/27 11:16:35 UTC

[GitHub] rafaelberrocalj edited a comment on issue #271: CB-7179 (iOS): Add WKWebView support for iOS

rafaelberrocalj edited a comment on issue #271: CB-7179 (iOS): Add WKWebView support for iOS
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/271#issuecomment-422866201
 
 
   > 
   > 
   > We have been testing this PR and it is working for us, but we did have to deal with local storage migration.
   
   Also "executeScript" seens not being working with localStorage, example:
   
   ```
   var APP = window.APP = window.APP || {};
   
   (function (base) {
   	"use strict";
   
   	this.isCordova = !!window.cordova;
   	this.startUrl = 'https://github.com/apache/cordova-plugin-inappbrowser';
   	this.appWindow = null;
   	this.popupConfig = 'hidden=no,location=no,toolbar=no,zoom=no,hidespinner=yes,usewkwebview=true';
   
   	this.loadUrl = function () {
   
   		if (APP.isCordova) {
   			try {
   				APP.appWindow = cordova.InAppBrowser.open(APP.startUrl, '_blank', APP.popupConfig);
   			} catch (e) {
   				alert('ERROR.InAppBrowser:' + JSON.stringify(e));
   			};
   		} else {
   			try {
   				APP.appWindow = window.open(APP.startUrl, '_blank', APP.popupConfig);
   			} catch (e) {
   				alert('ERROR.open:' + JSON.stringify(e));
   			};
   		};
   
   		alert('appWindoe.typeof:' + (typeof APP.appWindow));
   
   		if (APP.appWindow) {
   			APP.appWindow.addEventListener('loadstart', function () {
   				alert('loadstart');
   			});
   
   			APP.appWindow.addEventListener('loadstop', function () {
   				alert('loadstop');
   
   				APP.appWindow.executeScript({
   					code: "localStorage.setItem('keyTest', 'keyValue')"
   				}, function () {}, function () {
   					alert('setItem=' + JSON.stringify(arguments));
   
   					APP.appWindow.executeScript({
   						code: "localStorage.getItem('keyTest')"
   					}, function () {}, function () {
   						alert('getItem=' + JSON.stringify(arguments)); //should print something with "keyValue" but prints ""
   
   					});
   				});
   
   			});
   
   			APP.appWindow.addEventListener('loaderror', function () {
   				alert('loaderror');
   			});
   
   			APP.appWindow.addEventListener('exit', function () {
   				alert('exit');
   			});
   		};
   	};
   
   	this.onDeviceReady = function () {
   		alert('onDeviceReady');
   
   		try {
   			APP.loadUrl();
   		} catch (e) {
   			alert('ERROR.loadUrl:' + JSON.stringify(e));
   		};
   	};
   
   	var callReady = function () {
   		try {
   			APP.onDeviceReady();
   		} catch (e) {
   			alert('ERROR.callReady:' + JSON.stringify(e));
   		};
   	};
   
   	var readyTimeout = 3000;
   
   	if (this.isCordova) {
   		if (document.addEventListener) {
   			document.addEventListener('deviceready', function () {
   				callReady();
   			}, false);
   		} else {
   			setTimeout(function () {
   				callReady();
   			}, readyTimeout);
   		}
   	} else {
   		if (window.addEventListener) {
   			window.addEventListener('load', function () {
   				callReady();
   			}, false);
   		} else {
   			setTimeout(function () {
   				callReady();
   			}, readyTimeout);
   		};
   	};
   }).call(window.APP);
   ```
   
   edit: it's working 👍 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org