diff options
Diffstat (limited to 'StoneIsland/platforms/ios/www')
5 files changed, 192 insertions, 3 deletions
diff --git a/StoneIsland/platforms/ios/www/cordova_plugins.js b/StoneIsland/platforms/ios/www/cordova_plugins.js index 5d4c04be..770af107 100644 --- a/StoneIsland/platforms/ios/www/cordova_plugins.js +++ b/StoneIsland/platforms/ios/www/cordova_plugins.js @@ -138,6 +138,14 @@ module.exports = [ "clobbers": [ "PushNotification" ] + }, + { + "id": "cordova-plugin-wkwebview-engine.ios-wkwebview-exec", + "file": "plugins/cordova-plugin-wkwebview-engine/src/www/ios/ios-wkwebview-exec.js", + "pluginId": "cordova-plugin-wkwebview-engine", + "clobbers": [ + "cordova.exec" + ] } ]; module.exports.metadata = @@ -157,7 +165,8 @@ module.exports.metadata = "cordova-plugin-whitelist": "1.3.0", "cordova-plugin-x-socialsharing": "5.1.3", "ionic-plugin-keyboard": "2.2.1", - "phonegap-plugin-push": "2.0.0" + "phonegap-plugin-push": "2.0.0", + "cordova-plugin-wkwebview-engine": "1.1.3" }; // BOTTOM OF METADATA });
\ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/css/index.css b/StoneIsland/platforms/ios/www/css/index.css index a67e4bcf..4d8e5514 100755 --- a/StoneIsland/platforms/ios/www/css/index.css +++ b/StoneIsland/platforms/ios/www/css/index.css @@ -18,6 +18,7 @@ body { background: #fff; font-family: pfd, sans-serif; font-size: 12px; + padding-top: constant(safe-area-inset-top); } .loader { diff --git a/StoneIsland/platforms/ios/www/index.html b/StoneIsland/platforms/ios/www/index.html index 0b10cd52..a7c6bacb 100755 --- a/StoneIsland/platforms/ios/www/index.html +++ b/StoneIsland/platforms/ios/www/index.html @@ -16,7 +16,7 @@ <meta name="format-detection" content="telephone=no"> <meta name="msapplication-tap-highlight" content="no"> - <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> + <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, viewport-fit=cover"> <link rel="stylesheet" type="text/css" href="css/fonts/fonts.css"> <link rel="stylesheet" type="text/css" href="css/fonts/ionicons.css"> <link rel="stylesheet" type="text/css" href="css/vendor/flickity.css"> diff --git a/StoneIsland/platforms/ios/www/js/index.js b/StoneIsland/platforms/ios/www/js/index.js index a28faabf..72358e0e 100755 --- a/StoneIsland/platforms/ios/www/js/index.js +++ b/StoneIsland/platforms/ios/www/js/index.js @@ -4,7 +4,7 @@ var app = (function(){ app.init = function(){ console.log("init") - if (window.location.hostname === 'lvh.me' || window.location.hostname === 'stone.giraffe.life' || window.location.hostname === 'dev.stone.giraffe.life') { + if (window.location.hostname === 'lvh.me' || window.location.hostname === 'dev.stone.giraffe.life' || window.location.hostname === 'staging.stone.giraffe.life') { console.log('launching in test mode') sdk.init({ env: "test" }) } diff --git a/StoneIsland/platforms/ios/www/plugins/cordova-plugin-wkwebview-engine/src/www/ios/ios-wkwebview-exec.js b/StoneIsland/platforms/ios/www/plugins/cordova-plugin-wkwebview-engine/src/www/ios/ios-wkwebview-exec.js new file mode 100644 index 00000000..3a141228 --- /dev/null +++ b/StoneIsland/platforms/ios/www/plugins/cordova-plugin-wkwebview-engine/src/www/ios/ios-wkwebview-exec.js @@ -0,0 +1,179 @@ +cordova.define("cordova-plugin-wkwebview-engine.ios-wkwebview-exec", function(require, exports, module) { +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +/** + * Creates the exec bridge used to notify the native code of + * commands. + */ +var cordova = require('cordova'), + utils = require('cordova/utils'), + base64 = require('cordova/base64'); + +function massageArgsJsToNative(args) { + if (!args || utils.typeName(args) != 'Array') { + return args; + } + var ret = []; + args.forEach(function(arg, i) { + if (utils.typeName(arg) == 'ArrayBuffer') { + ret.push({ + 'CDVType': 'ArrayBuffer', + 'data': base64.fromArrayBuffer(arg) + }); + } else { + ret.push(arg); + } + }); + return ret; +} + +function massageMessageNativeToJs(message) { + if (message.CDVType == 'ArrayBuffer') { + var stringToArrayBuffer = function(str) { + var ret = new Uint8Array(str.length); + for (var i = 0; i < str.length; i++) { + ret[i] = str.charCodeAt(i); + } + return ret.buffer; + }; + var base64ToArrayBuffer = function(b64) { + return stringToArrayBuffer(atob(b64)); + }; + message = base64ToArrayBuffer(message.data); + } + return message; +} + +function convertMessageToArgsNativeToJs(message) { + var args = []; + if (!message || !message.hasOwnProperty('CDVType')) { + args.push(message); + } else if (message.CDVType == 'MultiPart') { + message.messages.forEach(function(e) { + args.push(massageMessageNativeToJs(e)); + }); + } else { + args.push(massageMessageNativeToJs(message)); + } + return args; +} + +var iOSExec = function() { + + // detect change in bridge, if there is a change, we forward to new bridge + + // if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.cordova && window.webkit.messageHandlers.cordova.postMessage) { + // bridgeMode = jsToNativeModes.WK_WEBVIEW_BINDING; + // } + + var successCallback, failCallback, service, action, actionArgs; + var callbackId = null; + if (typeof arguments[0] !== "string") { + // FORMAT ONE + successCallback = arguments[0]; + failCallback = arguments[1]; + service = arguments[2]; + action = arguments[3]; + actionArgs = arguments[4]; + + // Since we need to maintain backwards compatibility, we have to pass + // an invalid callbackId even if no callback was provided since plugins + // will be expecting it. The Cordova.exec() implementation allocates + // an invalid callbackId and passes it even if no callbacks were given. + callbackId = 'INVALID'; + } else { + throw new Error('The old format of this exec call has been removed (deprecated since 2.1). Change to: ' + + 'cordova.exec(null, null, \'Service\', \'action\', [ arg1, arg2 ]);'); + } + + // If actionArgs is not provided, default to an empty array + actionArgs = actionArgs || []; + + // Register the callbacks and add the callbackId to the positional + // arguments if given. + if (successCallback || failCallback) { + callbackId = service + cordova.callbackId++; + cordova.callbacks[callbackId] = + {success:successCallback, fail:failCallback}; + } + + actionArgs = massageArgsJsToNative(actionArgs); + + // CB-10133 DataClone DOM Exception 25 guard (fast function remover) + var command = [callbackId, service, action, JSON.parse(JSON.stringify(actionArgs))]; + window.webkit.messageHandlers.cordova.postMessage(command); + +}; + +iOSExec.nativeCallback = function(callbackId, status, message, keepCallback, debug) { + + var success = status === 0 || status === 1; + var args = convertMessageToArgsNativeToJs(message); + setTimeout(function(){ + cordova.callbackFromNative(callbackId, success, status, args, keepCallback); + }, 0); +}; + +// for backwards compatibility +iOSExec.nativeEvalAndFetch = function(func) { + try { + func(); + } catch (e) { + console.log(e); + } +}; + +// Proxy the exec for bridge changes. See CB-10106 + +function cordovaExec() { + var cexec = require('cordova/exec'); + var cexec_valid = (typeof cexec.nativeFetchMessages === 'function') && (typeof cexec.nativeEvalAndFetch === 'function') && (typeof cexec.nativeCallback === 'function'); + return (cexec_valid && execProxy !== cexec)? cexec : iOSExec; +} + +function execProxy() { + cordovaExec().apply(null, arguments); +} + +execProxy.nativeFetchMessages = function() { + return cordovaExec().nativeFetchMessages.apply(null, arguments); +}; + +execProxy.nativeEvalAndFetch = function() { + return cordovaExec().nativeEvalAndFetch.apply(null, arguments); +}; + +execProxy.nativeCallback = function() { + return cordovaExec().nativeCallback.apply(null, arguments); +}; + +module.exports = execProxy; + +if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.cordova && window.webkit.messageHandlers.cordova.postMessage) { + // unregister the old bridge + cordova.define.remove('cordova/exec'); + // redefine bridge to our new bridge + cordova.define("cordova/exec", function(require, exports, module) { + module.exports = execProxy; + }); +} +}); |
