From 20bc85a94d0d3b317411bd68e038c378b2592f00 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Mon, 12 Dec 2016 11:08:02 -0500 Subject: inital code - custom url scheme for #411. zmninja:// launches the app. zmninja:// takes us to live view for mid. needs more testing. --- config.xml | 6 ++++++ package.json | 9 ++++++++- www/js/app.js | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/config.xml b/config.xml index a8f2ef3a..4e71f473 100644 --- a/config.xml +++ b/config.xml @@ -93,4 +93,10 @@ + + + + + + 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:// 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 -- cgit v1.2.3