From ef14c875d7056f90be606ebf1f389c112b947f81 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 30 Nov 2015 23:07:12 -0500 Subject: canadian country code --- .../ios/StoneIsland/StoneIsland-Info.plist | 9 + StoneIsland/platforms/ios/www/cordova_plugins.js | 10 +- .../www/ios/LaunchMyApp.js | 11 + .../LaunchMyApp-PhoneGap-Plugin.iws | 1242 ++++++++++++++++++++ .../cordova-plugin-customurlscheme/README.md | 201 ++++ .../atlassian-ide-plugin.xml | 5 + .../cordova-plugin-customurlscheme/package.json | 43 + .../cordova-plugin-customurlscheme/plugin.xml | 107 ++ .../android/nl/xservices/plugins/LaunchMyApp.java | 136 +++ .../www/android/LaunchMyApp.js | 24 + .../www/ios/LaunchMyApp.js | 9 + .../www/windows/LaunchMyApp.js | 10 + StoneIsland/plugins/fetch.json | 10 + StoneIsland/plugins/ios.json | 10 + StoneIsland/www/js/lib/cart/CartShipping.js | 2 +- 15 files changed, 1827 insertions(+), 2 deletions(-) create mode 100644 StoneIsland/platforms/ios/www/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/LaunchMyApp-PhoneGap-Plugin.iws create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/README.md create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/atlassian-ide-plugin.xml create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/package.json create mode 100755 StoneIsland/plugins/cordova-plugin-customurlscheme/plugin.xml create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/src/android/nl/xservices/plugins/LaunchMyApp.java create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/www/android/LaunchMyApp.js create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js create mode 100644 StoneIsland/plugins/cordova-plugin-customurlscheme/www/windows/LaunchMyApp.js diff --git a/StoneIsland/platforms/ios/StoneIsland/StoneIsland-Info.plist b/StoneIsland/platforms/ios/StoneIsland/StoneIsland-Info.plist index 160c02b8..cc7d9214 100644 --- a/StoneIsland/platforms/ios/StoneIsland/StoneIsland-Info.plist +++ b/StoneIsland/platforms/ios/StoneIsland/StoneIsland-Info.plist @@ -182,5 +182,14 @@ remote-notification + CFBundleURLTypes + + + CFBundleURLSchemes + + stoneisland + + + \ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/cordova_plugins.js b/StoneIsland/platforms/ios/www/cordova_plugins.js index fbdc76c9..99a9e96f 100644 --- a/StoneIsland/platforms/ios/www/cordova_plugins.js +++ b/StoneIsland/platforms/ios/www/cordova_plugins.js @@ -91,6 +91,13 @@ module.exports = [ "clobbers": [ "PushNotification" ] + }, + { + "file": "plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js", + "id": "cordova-plugin-customurlscheme.LaunchMyApp", + "clobbers": [ + "window.plugins.launchmyapp" + ] } ]; module.exports.metadata = @@ -104,7 +111,8 @@ module.exports.metadata = "cordova-plugin-geolocation": "1.0.1", "cordova-plugin-network-information": "1.0.1", "cordova-plugin-splashscreen": "2.1.0", - "phonegap-plugin-push": "1.4.4" + "phonegap-plugin-push": "1.4.4", + "cordova-plugin-customurlscheme": "4.0.0" } // BOTTOM OF METADATA }); \ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js b/StoneIsland/platforms/ios/www/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js new file mode 100644 index 00000000..3568c73f --- /dev/null +++ b/StoneIsland/platforms/ios/www/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js @@ -0,0 +1,11 @@ +cordova.define("cordova-plugin-customurlscheme.LaunchMyApp", function(require, exports, module) { "use strict"; + +/* + Q: Why an empty file? + A: iOS doesn't need plumbing to get the plugin to work, so.. + - Including no file would mean the import in index.html would differ per platform. + - Also, using one version and adding a userAgent check for Android feels wrong. + - And if you're not using PhoneGap Build, you could paste your handleOpenUrl JS function here. +*/ + +}); diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/LaunchMyApp-PhoneGap-Plugin.iws b/StoneIsland/plugins/cordova-plugin-customurlscheme/LaunchMyApp-PhoneGap-Plugin.iws new file mode 100644 index 00000000..9879f7f4 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/LaunchMyApp-PhoneGap-Plugin.iws @@ -0,0 +1,1242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + + 1380298653954 + + + 1380299229689 + + + 1380302935690 + + + 1380305538088 + + + 1380305862564 + + + 1380306489891 + + + 1380307532008 + + + 1380307669209 + + + 1380311306948 + + + 1380311921427 + + + 1380317008739 + + + 1380317829887 + + + 1380353871771 + + + 1380358237732 + + + 1380358605885 + + + 1380376149014 + + + 1380378153190 + + + 1380383948466 + + + 1380393159906 + + + 1380393508799 + + + 1380393757355 + + + 1380393772924 + + + 1380402190419 + + + 1380402398063 + + + 1380402815702 + + + 1380488689110 + + + 1380488797067 + + + 1380488875151 + + + 1380489049263 + + + 1380489820453 + + + 1380567506465 + + + 1380567576964 + + + 1380567665822 + + + 1383169425770 + + + 1383172326587 + + + 1383174045796 + + + 1390857761557 + + + 1390857936690 + + + 1391028041914 + + + 1402048017666 + + + 1417632494865 + + + 1417703047123 + + + 1417706007258 + + + 1434477311221 + + + 1434530307503 + + + 1434577022103 + + + 1435161053225 + + + 1440664137793 + + + 1440664585797 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/README.md b/StoneIsland/plugins/cordova-plugin-customurlscheme/README.md new file mode 100644 index 00000000..2de829c2 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/README.md @@ -0,0 +1,201 @@ +# Custom URL scheme PhoneGap Plugin +#### launch your app by a link like this: `mycoolapp://` +for iOS and Android, by [Eddy Verbruggen](http://www.x-services.nl) +- This repo is for PhoneGap 3.0.0 and up +- For PhoneGap 2.9.0 and lower, [switch to the phonegap-2.9.0-and-lower branch](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin/tree/phonegap-2.9.0-and-lower) + +1. [Description](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#1-description) +2. [Installation](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#2-installation) + 2. [Automatically (CLI / Plugman)](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#automatically-cli--plugman) + 2. [Manually](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#manually) + 2. [PhoneGap Build](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#phonegap-build) +3. [Usage](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#3-usage) +4. [URL Scheme hints](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#4-url-scheme-hints) +5. [License](https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin#5-license) + + +### BEWARE: [This Apache Cordova issue](https://issues.apache.org/jira/browse/CB-7606) causes problems with Cordova-iOS 3.7.0: the `handleOpenURL` function is not invoked upon cold start. Use a higher or lower version than 3.7.0. + +## 1. Description + +This plugin allows you to start your app by calling it with a URL like `mycoolapp://path?foo=bar` + +* Compatible with [Cordova Plugman](https://github.com/apache/cordova-plugman) +* Submitted and waiting for approval at PhoneGap Build ([more information](https://build.phonegap.com/plugins)) + +### iOS specifics +* Forget about [using config.xml to define a URL scheme](https://build.phonegap.com/docs/config-xml#url_schemes). This plugin adds 2 essential enhancements: + - Uniform URL scheme with Android (for which there is no option to define a URL scheme via PhoneGap configuration at all). + - You still need to wire up the Javascript to handle incoming events. This plugin assists you with that. +* Tested on iOS 5.1, 6 and 7. + +### Android specifics +* Unlike iOS, there is no way to use config.xml to define a scheme for your app. Now there is. +* Tested on Android 4.3, will most likely work with 2.2 and up. + + +## 2. Installation + +### Automatically (CLI / Plugman) +LaunchMyApp is compatible with [Cordova Plugman](https://github.com/apache/cordova-plugman). +Replace `mycoolapp` by a nice scheme you want to have your app listen to: + +Latest release on npm: +``` +$ cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=mycoolapp +``` + +Bleeding edge master version from Github: +``` +$ cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=mycoolapp +``` +(Note that the Phonegap CLI didn't support `--variable` before version 3.6.3, so please use the Cordova CLI as shown above in case you're on an older version) + +The LaunchMyApp.js file is brought in automatically. + +Note for iOS: there was a bug in CLI which caused an error in your `*-Info.plist`. +Please manually remove the blank line and whitespace (if any) from `NSMainNibFile` and `NSMainNibFile~ipad` (or your app won't start at all). + + +### Manually +Don't shoot yourself in the foot - use the CLI! That being said, here goes: + +#### iOS +1\. `Copy www/ios/LaunchMyApp.js` to `www/js/plugins/LaunchMyApp.js` and reference it in your `index.html`: +```html + +``` + +2\. Add this to your `*-Info.plist` (replace `URL_SCHEME` by a nice scheme you want to have your app listen to, like `mycoolapp`): +```xml +CFBundleURLTypes + + + CFBundleURLSchemes + + URL_SCHEME + + + +``` + +#### Android +1\. Copy www/android/LaunchMyApp.js to www/js/plugins/LaunchMyApp.js and reference it in your `index.html`: +```html + +``` + +2\. Add the following xml to your `config.xml` to always use the latest version of this plugin: +```xml + +``` + +3\. Copy `LaunchMyApp.java` to `platforms/android/src/nl/xservices/plugins` (create the folders) + +4\. Add the following to your `AndroidManifest.xml` inside the `/manifest/application/activity` node (replace `URL_SCHEME` by a nice scheme you want to have your app listen to, like `mycoolapp`): +```xml + + + + + + +``` + +5\. In `AndroidManifest.xml` set the launchMode to singleTask to avoid issues like [#24]. ` + + +``` + +The LaunchMyApp.js file is brought in automatically. + +NOTE: When Hydration is enabled at PGB, this plugin may not work. + +### Restoring cordova plugin settings on plugin add or update +In order to be able to restore the plugin settings on `cordova plugin add`, one need to add the following feature into config.xml. Note that if you added the plugin with the `--save` param you will find this in your `config.xml` already, except for the `variable` tag which is likely a `param` tag. [Change that.](https://github.com/EddyVerbruggen/Custom-URL-scheme/issues/76) +```xml + + + + + +``` + +Please notice that URL_SCHEME is saved as `variable`, not as `prop`. However if you do `cordova plugin add` with a --save option, cordova will write the URL_SCHEME as a `prop`, you need to change the tag name from `param` to `variable` in this case. + +These plugin restore instructions are tested on: +cordova-cli 4.3.+ and cordova-android 3.7.1+ + + +## 3. Usage + +1a\. Your app can be launced by linking to it like this from a website or an email for example (all of these will work): +```html +Open my app +Open my app +Open my app +Open my app +``` + +`mycoolapp` is the value of URL_SCHEME you used while installing this plugin. + +1b\. If you're trying to open your app from another PhoneGap app, use the InAppBrowser plugin and launch the receiving app like this, to avoid a 'protocol not supported' error: +```html + +``` + +2\. When your app is launched by a URL, you probably want to do something based on the path and parameters in the URL. For that, you could implement the (optional) `handleOpenURL(url)` method, which receives the URL that was used to launch your app. +```javascript +function handleOpenURL(url) { + console.log("received url: " + url); +} +``` + +If you want to alert the URL for testing the plugin, at least on iOS you need to wrap it in a timeout like this: +```javascript +function handleOpenURL(url) { + setTimeout(function() { + alert("received url: " + url); + }, 0); +} +``` +A more useful implementation would mean parsing the URL, saving any params to sessionStorage and redirecting the app to the correct page inside your app. +All this happens before the first page is loaded. + +## 4. URL Scheme hints +Please choose a URL_SCHEME which which complies to these restrictions: +- Don't use an already registered scheme (like `fb`, `twitter`, `comgooglemaps`, etc). +- Use only lowercase characters. +- Don't use a dash `-` because on Android it will become underscore `_`. +- Use only 1 word (no spaces). + +TIP: test your scheme by installing the app on a device or simulator and typing yourscheme:// in the browser URL bar, or create a test HTML page with a link to your app to impress your buddies. + + +## 5. License + +[The MIT License (MIT)](http://www.opensource.org/licenses/mit-license.html) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/atlassian-ide-plugin.xml b/StoneIsland/plugins/cordova-plugin-customurlscheme/atlassian-ide-plugin.xml new file mode 100644 index 00000000..858eed55 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/atlassian-ide-plugin.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/package.json b/StoneIsland/plugins/cordova-plugin-customurlscheme/package.json new file mode 100644 index 00000000..de90c8e2 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/package.json @@ -0,0 +1,43 @@ +{ + "name": "cordova-plugin-customurlscheme", + "version": "4.0.0", + "description": "Launch your app by using this URL: mycoolapp://, you can add a path and even pass params like this: mycoolerapp://somepath?foo=bar", + "cordova": { + "id": "cordova-plugin-customurlscheme", + "platforms": [ + "ios", + "android", + "windows8", + "windows" + ] + }, + "repository": { + "type": "git", + "url": "git+https://github.com/EddyVerbruggen/Custom-URL-scheme.git" + }, + "keywords": [ + "Custom URL Scheme", + "URLscheme", + "URL scheme", + "Custom URL", + "Launch My App", + "Launch App", + "ecosystem:cordova", + "cordova-ios", + "cordova-android", + "cordova-windows", + "cordova-windows8" + ], + "engines": [ + { + "name": "cordova", + "version": ">=3.0.0" + } + ], + "author": "Eddy Verbruggen (https://github.com/EddyVerbruggen)", + "license": "MIT", + "bugs": { + "url": "https://github.com/EddyVerbruggen/Custom-URL-scheme/issues" + }, + "homepage": "https://github.com/EddyVerbruggen/Custom-URL-scheme#readme" +} \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/plugin.xml b/StoneIsland/plugins/cordova-plugin-customurlscheme/plugin.xml new file mode 100755 index 00000000..1e43e724 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/plugin.xml @@ -0,0 +1,107 @@ + + + + Custom URL scheme + + + Launch your app by using this URL: mycoolapp:// + You can add a path and even pass params like this: mycoolerapp://somepath?foo=bar + + + Eddy Verbruggen + + MIT + + Custom URL Scheme, URLscheme, URL scheme, Custom URL, Launch My App, Launch App + + https://github.com/EddyVerbruggen/Custom-URL-scheme.git + + https://github.com/EddyVerbruggen/Custom-URL-scheme/issues + + + + + + + + + + + + + + + + + CFBundleURLSchemes + + $URL_SCHEME + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/src/android/nl/xservices/plugins/LaunchMyApp.java b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/android/nl/xservices/plugins/LaunchMyApp.java new file mode 100644 index 00000000..9d3f3d63 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/android/nl/xservices/plugins/LaunchMyApp.java @@ -0,0 +1,136 @@ +package nl.xservices.plugins; + +import android.content.Intent; +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaActivity; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.PluginResult; +import org.json.JSONArray; +import org.json.JSONException; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Locale; + +public class LaunchMyApp extends CordovaPlugin { + + private static final String ACTION_CHECKINTENT = "checkIntent"; + + @Override + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { + if (ACTION_CHECKINTENT.equalsIgnoreCase(action)) { + final Intent intent = ((CordovaActivity) this.webView.getContext()).getIntent(); + final String intentString = intent.getDataString(); + if (intentString != null && intentString.contains("://") && intent.getScheme() != null) { + callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, intent.getDataString())); + intent.setData(null); + } else { + callbackContext.error("App was not started via the launchmyapp URL scheme. Ignoring this errorcallback is the best approach."); + } + return true; + } else { + callbackContext.error("This plugin only responds to the " + ACTION_CHECKINTENT + " action."); + return false; + } + } + + @Override + public void onNewIntent(Intent intent) { + final String intentString = intent.getDataString(); + if (intentString != null && intentString.contains("://") && intent.getScheme() != null) { + intent.setData(null); + try { + StringWriter writer = new StringWriter(intentString.length() * 2); + escapeJavaStyleString(writer, intentString, true, false); + webView.loadUrl("javascript:handleOpenURL('" + writer.toString() + "');"); + } catch (IOException ignore) { + } + } + } + + // Taken from commons StringEscapeUtils + private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote, + boolean escapeForwardSlash) throws IOException { + if (out == null) { + throw new IllegalArgumentException("The Writer must not be null"); + } + if (str == null) { + return; + } + int sz; + sz = str.length(); + for (int i = 0; i < sz; i++) { + char ch = str.charAt(i); + + // handle unicode + if (ch > 0xfff) { + out.write("\\u" + hex(ch)); + } else if (ch > 0xff) { + out.write("\\u0" + hex(ch)); + } else if (ch > 0x7f) { + out.write("\\u00" + hex(ch)); + } else if (ch < 32) { + switch (ch) { + case '\b': + out.write('\\'); + out.write('b'); + break; + case '\n': + out.write('\\'); + out.write('n'); + break; + case '\t': + out.write('\\'); + out.write('t'); + break; + case '\f': + out.write('\\'); + out.write('f'); + break; + case '\r': + out.write('\\'); + out.write('r'); + break; + default: + if (ch > 0xf) { + out.write("\\u00" + hex(ch)); + } else { + out.write("\\u000" + hex(ch)); + } + break; + } + } else { + switch (ch) { + case '\'': + if (escapeSingleQuote) { + out.write('\\'); + } + out.write('\''); + break; + case '"': + out.write('\\'); + out.write('"'); + break; + case '\\': + out.write('\\'); + out.write('\\'); + break; + case '/': + if (escapeForwardSlash) { + out.write('\\'); + } + out.write('/'); + break; + default: + out.write(ch); + break; + } + } + } + } + + private static String hex(char ch) { + return Integer.toHexString(ch).toUpperCase(Locale.ENGLISH); + } +} \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/www/android/LaunchMyApp.js b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/android/LaunchMyApp.js new file mode 100644 index 00000000..19dbdc0b --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/android/LaunchMyApp.js @@ -0,0 +1,24 @@ +(function () { + "use strict"; + + var remainingAttempts = 10; + + function waitForAndCallHandlerFunction(url) { + if (typeof window.handleOpenURL == "function") { + window.handleOpenURL(url); + } else if (remainingAttempts-- > 0) { + setTimeout(function(){waitForAndCallHandlerFunction(url)}, 500); + } + } + + function triggerOpenURL() { + cordova.exec( + waitForAndCallHandlerFunction, + null, + "LaunchMyApp", + "checkIntent", + []); + } + + document.addEventListener("deviceready", triggerOpenURL, false); +}()); diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js new file mode 100644 index 00000000..a1d60818 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js @@ -0,0 +1,9 @@ +"use strict"; + +/* + Q: Why an empty file? + A: iOS doesn't need plumbing to get the plugin to work, so.. + - Including no file would mean the import in index.html would differ per platform. + - Also, using one version and adding a userAgent check for Android feels wrong. + - And if you're not using PhoneGap Build, you could paste your handleOpenUrl JS function here. +*/ diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/www/windows/LaunchMyApp.js b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/windows/LaunchMyApp.js new file mode 100644 index 00000000..a70d5e94 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/www/windows/LaunchMyApp.js @@ -0,0 +1,10 @@ +(function () { + function activatedHandler(e) { + if (typeof handleOpenURL == 'function' && e.uri) { + handleOpenURL(e.uri.rawUri); + } + }; + + var wui = Windows.UI.WebUI.WebUIApplication; + wui.addEventListener("activated", activatedHandler, false); +}()); diff --git a/StoneIsland/plugins/fetch.json b/StoneIsland/plugins/fetch.json index b57114f3..59ddd3e7 100644 --- a/StoneIsland/plugins/fetch.json +++ b/StoneIsland/plugins/fetch.json @@ -70,5 +70,15 @@ }, "is_top_level": true, "variables": {} + }, + "cordova-plugin-customurlscheme": { + "source": { + "type": "registry", + "id": "cordova-plugin-customurlscheme" + }, + "is_top_level": true, + "variables": { + "URL_SCHEME": "stoneisland" + } } } \ No newline at end of file diff --git a/StoneIsland/plugins/ios.json b/StoneIsland/plugins/ios.json index 337f2532..2a7a09ab 100644 --- a/StoneIsland/plugins/ios.json +++ b/StoneIsland/plugins/ios.json @@ -84,6 +84,12 @@ "xml": "remote-notification", "count": 1 } + ], + "CFBundleURLTypes": [ + { + "xml": "CFBundleURLSchemesstoneisland", + "count": 1 + } ] } } @@ -116,6 +122,10 @@ }, "phonegap-plugin-push": { "PACKAGE_NAME": "io.cordova.hellocordova" + }, + "cordova-plugin-customurlscheme": { + "URL_SCHEME": "stoneisland", + "PACKAGE_NAME": "io.cordova.hellocordova" } }, "dependent_plugins": {} diff --git a/StoneIsland/www/js/lib/cart/CartShipping.js b/StoneIsland/www/js/lib/cart/CartShipping.js index 1a9653e1..9b8205c1 100644 --- a/StoneIsland/www/js/lib/cart/CartShipping.js +++ b/StoneIsland/www/js/lib/cart/CartShipping.js @@ -101,7 +101,7 @@ var CartShipping = FormView.extend({ shipping_info.City = address_data.City shipping_info.Province = address_data.Province shipping_info.Region = address_data.Province - shipping_info.CountryCode = "US" + shipping_info.CountryCode = CANADIAN_LOOKUP[ address_data.Province ] ? "CA" : "US" return shipping_info }, -- cgit v1.2.3-70-g09d2