Skip to content
This repository was archived by the owner on Sep 15, 2021. It is now read-only.

Commit 13676c1

Browse files
Wikitude cordova plugin added
1 parent 2605cfe commit 13676c1

File tree

1 file changed

+146
-1
lines changed

1 file changed

+146
-1
lines changed

dist/ng-cordova.js

Lines changed: 146 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5589,6 +5589,7 @@ angular.module('ngCordova.plugins', [
55895589
'ngCordova.plugins.touchid',
55905590
'ngCordova.plugins.vibration',
55915591
'ngCordova.plugins.videoCapturePlus',
5592+
'ngCordova.plugins.wikitudePlugin',
55925593
'ngCordova.plugins.zip',
55935594
'ngCordova.plugins.insomnia'
55945595
]);
@@ -7031,6 +7032,150 @@ angular.module('ngCordova.plugins.videoCapturePlus', [])
70317032
};
70327033
}];
70337034
}]);
7035+
7036+
// install : cordova plugin add https://github.com/Wikitude/wikitude-cordova-plugin.git
7037+
7038+
angular.module('ngCordova.plugins.wikitudePlugin', [])
7039+
7040+
.factory('$wikitudePlugin', ['$q', '$window', '$exceptionHandler', function ($q, $window, $exceptionHandler) {
7041+
7042+
return {
7043+
/**
7044+
* internal listeners for success and error, they are invoked in cordova.exec() function
7045+
*/
7046+
setInternalListeners: function () {
7047+
$window.plugins.wikitudePlugin.prototype.onWikitudeOK = function (success) {
7048+
//success callback
7049+
};
7050+
7051+
$window.plugins.wikitudePlugin.prototype.onWikitudeError = function (error) {
7052+
// error callback
7053+
throw (error);
7054+
};
7055+
},
7056+
7057+
/**
7058+
* array of requiredFeatures for instance [ "2d_tracking", "geo" ]
7059+
* if no argument is passed the default value is 2d tracking
7060+
* @param requiredFeatures
7061+
* @returns {*}
7062+
*/
7063+
isDeviceSupported: function(requiredFeatures) {
7064+
7065+
// set the internal listeners for success and error
7066+
this.setInternalListeners();
7067+
7068+
var self = this;
7069+
var q = $q.defer();
7070+
7071+
// store features in the $wikitudePlugin for accessing it in all methods
7072+
self.features = requiredFeatures || [ '2d_tracking' ];
7073+
7074+
$window.plugins.wikitudePlugin.isDeviceSupported(function () {
7075+
//device supported
7076+
q.resolve(self);
7077+
}, function () {
7078+
//device not supported
7079+
q.reject('device not supported!');
7080+
}, self.features);
7081+
7082+
return q.promise;
7083+
},
7084+
7085+
/**
7086+
*
7087+
* @param worldPath
7088+
* @param startupConfiguration
7089+
*/
7090+
loadARchitectWorld: function (worldPath, startupConfiguration) {
7091+
var q = $q.defer();
7092+
7093+
// startup configuration converted to json
7094+
var config = JSON.stringify( startupConfiguration || { 'camera_position': 'back' } );
7095+
7096+
if (typeof worldPath === 'string') {
7097+
7098+
$window.plugins.wikitudePlugin.loadARchitectWorld(function (loadedURL) {
7099+
// loadedSuccessful
7100+
q.resolve(loadedURL);
7101+
}, function (errorMessage) {
7102+
// error local path is wrong or the remote url returned an error code
7103+
q.reject(errorMessage);
7104+
},worldPath, this.features, config);
7105+
}
7106+
7107+
return q.promise;
7108+
},
7109+
7110+
/**
7111+
* inject a location into the Wikitude SDK
7112+
* @param latitude
7113+
* @param longitude
7114+
* @param altitude
7115+
* @param accuracy
7116+
*/
7117+
setLocation: function (latitude, longitude, altitude, accuracy) {
7118+
try {
7119+
//inject a location into the Wikitude SDK
7120+
$window.plugins.wikitudePlugin.setLocation(latitude, longitude, altitude, accuracy);
7121+
} catch (e) {
7122+
// handle execption
7123+
$exceptionHandler(e.message);
7124+
}
7125+
},
7126+
7127+
/**
7128+
* The first argument Indicates if the ARchitect
7129+
* web view should be included in the generated screenshot or not.
7130+
* If a file path or file name is given in the second argument,
7131+
* the generated screenshot will be saved in the application bundle.
7132+
* Passing null will save the photo in the device photo library
7133+
* @param includeWebView
7134+
* @param imagePath
7135+
* @returns {*}
7136+
*/
7137+
captureScreen: function (includeWebView, imagePath) {
7138+
var q = $q.defer();
7139+
7140+
$window.plugins.wikitudePlugin.captureScreen(includeWebView, imagePath, function (bundlePath) {
7141+
//success
7142+
q.resolve(bundlePath);
7143+
}, function (error) {
7144+
//error
7145+
q.reject(error);
7146+
});
7147+
7148+
return q.promise;
7149+
},
7150+
7151+
callJavaScript: function (js) {
7152+
try {
7153+
$window.plugins.wikitudePlugin.callJavaScript(js);
7154+
} catch (e) {
7155+
$exceptionHandler(e);
7156+
}
7157+
},
7158+
7159+
setOnUrlInvokeCallback: function (onUrlInvokeCallback) {
7160+
$window.plugins.wikitudePlugin.setOnUrlInvokeCallback(onUrlInvokeCallback);
7161+
},
7162+
7163+
7164+
close: function () {
7165+
$window.plugins.wikitudePlugin.close();
7166+
},
7167+
7168+
show: function () {
7169+
$window.plugins.wikitudePlugin.show();
7170+
},
7171+
7172+
hide: function () {
7173+
$window.plugins.wikitudePlugin.hide();
7174+
}
7175+
7176+
};// end of wikitudePlugin factory
7177+
7178+
}]);
70347179

70357180
// install : cordova plugin add https://github.com/MobileChromeApps/zip.git
70367181
// link : https://github.com/MobileChromeApps/zip
@@ -7058,4 +7203,4 @@ angular.module('ngCordova.plugins.zip', [])
70587203
};
70597204
}]);
70607205

7061-
})();
7206+
})();

0 commit comments

Comments
 (0)