diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2016-12-12 11:08:02 -0500 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2016-12-12 11:08:02 -0500 |
| commit | 20bc85a94d0d3b317411bd68e038c378b2592f00 (patch) | |
| tree | 0428c03c9989a9f62c078dcc790d6a8a9992292f | |
| parent | 222673f7069cd90bef56e9205b9905301c1ac95b (diff) | |
inital code - custom url scheme for #411. zmninja:// launches the app. zmninja://<mid> takes us to live view for mid. needs more testing.
| -rw-r--r-- | config.xml | 6 | ||||
| -rw-r--r-- | package.json | 9 | ||||
| -rw-r--r-- | www/js/app.js | 37 |
3 files changed, 51 insertions, 1 deletions
@@ -93,4 +93,10 @@ <plugin name="cordova-plugin-photo-library" spec="~1.2.0"> <variable name="PHOTO_LIBRARY_USAGE_DESCRIPTION" value="images to gallery" /> </plugin> + <plugin name="cordova-plugin-customurlscheme" spec="~4.2.0"> + <variable name="URL_SCHEME" value="zmninja" /> + <variable name="ANDROID_SCHEME" value=" " /> + <variable name="ANDROID_HOST" value=" " /> + <variable name="ANDROID_PATHPREFIX" value="/" /> + </plugin> </widget> diff --git a/package.json b/package.json index 7896aebc..f6f0113e 100644 --- a/package.json +++ b/package.json @@ -90,16 +90,23 @@ "locator": "https://github.com/pliablepixels/cordova-plugin-media", "id": "cordova-plugin-media" }, - "cordova-plugin-photo-library", "cordova-plugin-add-swift-support", "cordova-plugin-file-transfer", { "locator": "https://github.com/FlyingDonkeyDev/cordova-library-helper", "id": "cordova-library-helper" }, + "cordova-plugin-photo-library", { "locator": "https://github.com/hypery2k/cordova-certificate-plugin", "id": "cordova-plugin-certificates" + }, + { + "id": "cordova-plugin-customurlscheme", + "locator": "cordova-plugin-customurlscheme", + "variables": { + "URL_SCHEME": "zmninja" + } } ], "cordovaPlatforms": [ diff --git a/www/js/app.js b/www/js/app.js index d07d0e5d..7027ff42 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1355,6 +1355,19 @@ angular.module('zmApp', [ }); + // credit http://stackoverflow.com/a/2091331/1361529 + function getQueryVariable(query, variable) { + var vars = query.split('&'); + for (var i = 0; i < vars.length; i++) { + var pair = vars[i].split('='); + if (decodeURIComponent(pair[0]) == variable) { + return decodeURIComponent(pair[1]); + } + } + return ""; + //console.log('Query variable %s not found', variable); + } + //--------------------------------------------------------------------- // called when device is ready //--------------------------------------------------------------------- @@ -1368,6 +1381,27 @@ angular.module('zmApp', [ $ionicPlatform.ready(function() { + // handles URL launches + // if you just launch zmninja:// then it will honor the settings in "tap screen" -> events or montage + // if you launch with zmninja://<mid> it will take you to live view for that mid + window.handleOpenURL = function(url) { + $rootScope.tappedNotification = 1; + $rootScope.tappedMid = 0; + var c= URI.parse(url); + //NVRDataModel.log ("***********launched with "+ JSON.stringify(c)); + if (c.query) + { + var qm = getQueryVariable(c.query, "mid"); + if (qm) $rootScope.tappedMid = parseInt(qm); + NVRDataModel.log ("external URL called with MID="+$rootScope.tappedMid); + //console.log (">>>>>>>>> EID="+getQueryVariable(c.query, "eid")); + + } + + + + }; + $rootScope.textScaleFactor = 1.0; $rootScope.db = null; @@ -1784,6 +1818,9 @@ angular.module('zmApp', [ } + // URL interceptor + + }); //platformReady }) //run |
