I'm trying to implement ezar to ionic but can't use it. I did ionic cordova plugin add com.ezartech.ezar.videooverlay
window["plugins"].ezar
.initializeVideoOverlay(
function () {
window["plugins"].ezar.getBackCamera().start();
document.body.style.backgroundColor = 'transparent';
},
function (err) {
alert('unable to init ezar: ' + err);
});
It can't find ezar says undefined
I tried without window[] but couldn't succeed it also I can't import at ts file because its not installed as a component. Do you have any idea?
Thank you
This worked for me:
var win: any = window;
if (win.ezar) {
var ezar: any = win.ezar;
ezar.initializeVideoOverlay(
function() {
ezar.getBackCamera().start();
},
function(err) { alert(JSON.stringify(err));
}, {fitWebViewToCameraView: true});
} else {
alert('Unable to detect the ezAR plugin');
}
Try window["ezar"] in place of window["plugins"].ezar
Worked for me (although getting ezAR to work with ionic 3 in general is quite difficult with the lack of documentation)
Related
I am using Ionic version 5.4.16 and i am trying to close the app by hardware back button with a alert message for confirm to exit. I have checked a lot of tutorials for the same and everywhere i saw 2 ways to achieve that --
this.platform.exitApp();
and
navigator.app.exitapp()
and
navigator.["app"].exitapp();
But none of these option are working in Ionic 5, its not recognizing the function exitApp().
So how to achieve the same if anyone has faced the same issue do suggest, thank you.
To close the app, you must configure the following:
import { Plugins } from '#capacitor/core';
const { App } = Plugins;
App.exitApp();
Try to paste this code.
public unsubscribeBackEvent: any;
ionViewDidEnter() {
this.initializeBackButtonCustomHandler();
}
initializeBackButtonCustomHandler(): void {
this.unsubscribeBackEvent = this.platform.backButton.subscribeWithPriority(999999, () => {
if(window.confirm('Do you want to exit the app?'))
{
navigator['app'].exitApp();
}
});
}
ionViewWillLeave() {
this.unsubscribeBackEvent.unsubscribe();
}
I hope it's done.
I have implemented Direct Update in Ionic3 application. Direct Update notification has received, downloaded successfully but UI changes are not getting reflected in application.Please help.
Code Snippet:
declare var WL;
declare var wl_directUpdateChallengeHandler;
constructor(public platform: Platform){
renderer.listenGlobal('document', 'mfpjsloaded', () => {
console.log('--> MyApp mfpjsloaded');
this.directUpdateHandler();
this.checkWebUpdate();
})
}
checkWebUpdate(){
console.log('--> checkWebUpdate called');
WLAuthorizationManager.obtainAccessToken()
.then(
(accessToken) => {
console.log('--> AuthHandler: obtainAccessToken onSuccess'+JSON.stringify(accessToken));
},
(error) => {
console.log('--> AuthHandler: obtainAccessToken onFailure: ' + JSON.stringify(error));
}
);
}
directUpdateHandler(){
console.log('--> MyApp directUpdateHandler called');
wl_directUpdateChallengeHandler.handleDirectUpdate =
function(directUpdateData, directUpdateContext) {
WL.SimpleDialog.show('Update Avalible',' Press update button to
download new version', [{
text :'update',
handler : function() {
directUpdateContext.start();
}
}]);
};
}
Since you have missed implementing directUpdateCustomListener, You are facing this issue.
Two ways to solve this issue :
Try Direct Update feature without using directUpdateHandler function, it will work.
If you are planning to customise the UI for direct update, You have write full definition of the DU which includes implementation of directUpdateCustomListener as well. This is mentioned in the following documentation.
I'm using InAppBrowser in my Ionic project the problem is adding new event listener as in the documentation of ionic-native is not working at all, I referred to original cordova-plugin-inappbrowser and none of these events are working, I know this is issue from Ionic wrapping side and their poor documentation, they change the whole way of calling plugin and you need to try until you get the right way.
So I'm asking how to add the event listeners to InAppBrowser plugin?
What I tried until now is:
var _options = 'location=no,clearsessioncache=yes,hardwareback=no';
function openLink(url, target, options) {
if (angular.isUndefined(options)) {
options = _options;
}
if (!$window.cordova) {
$window.open(url, '_blank', options);
} else {
_attachEvents(new $cordovaInAppBrowser(url, target, options));
}
}
function _attachEvents(browser) {
// FIXME this is not working seems, need to find documentation about this
browser.on('loadstart').subscribe(function (e, event) {
console.debug(e, event);
if (event.url.match("mobile/close")) {
browser.close();
}
$rootScope.$broadcast('$ionicParentView.enter');
});
browser.on('loaderror').subscribe(function (e, event) {
console.debug(e, event);
browser.close();
$rootScope.$broadcast('$ionicParentView.enter');
});
}
And tried ngCordova way:
$rootScope.$on('$cordovaInAppBrowser:loadstart', function (e, event) {
if (event.url.match("mobile/close")) {
$cordovaInAppBrowser.close();
}
$rootScope.$broadcast('$ionicParentView.enter');
});
$rootScope.$on('$cordovaInAppBrowser:loaderror', function (e, event) {
$cordovaInAppBrowser.close();
$rootScope.$broadcast('$ionicParentView.enter');
});
And they are not working, BTW, it was working with ngCordova but since I changed to ionic-native, it stopped working at all.
I'm using Ionic 1.3.2 with ionic-native 2.2.16 (since 2.2.17 and 2.3.0 are broken builds)
I´m new to Ionic2, but experienced in web development. Just learning new platform at the moment.
So I have tried to integrate the Anyline OCR SDK
https://github.com/Anyline/anyline-ocr-cordova-module
but I am failing, it seems to me that the plugin is written in Javascript and not compatible with TS but I´m not sure...
Is there anyone out there that could help?
Thanks,
Ben
Not sure if you still need help with that, but for those out there who are looking for a working solution, here is mine:
1 - Add the Anyline Plugin to your project cordova plugin add io-anyline-cordova
2 - Create a new file ionic g provider anyline
3 - add this code to your anyline.ts file:
export class OCR {
constructor() {
if (anylineScan === undefined) {
var anylineScan = {};
}
}
anylineScan = {
onResult: function (result) {
console.log("MRZ result: " + JSON.stringify(result));
//do what you want here with the result
},
onError: function (error) {
console.log("scanning error");
},
scan: function () {
var licenseKey = "enterYourLicenceKeyHere";
try {
(<any>window).cordova.exec(this.onResult, this.onError, "AnylineSDK", "OCR", [licenseKey, {
"captureResolution":"1080p",
//your other config setting here
}]);
}
catch (e){
console.log("Cannot open scan view: ERROR occurred");
}
}
}
4 - Add the file references to your app.module.ts file
import { OCR } from '../yourFolderName/anyline';
...
providers: [Storage, OCR]
5 - In your page.ts file add the following call:
this.anyline.anylineScan.scan();
Important! It will not work in the browser, make sure you run ionic platform add ios (or android) and run the app on a device.
This should work!
Good luck and happy coding :-)
I trying to learn SmartFace App Development Platform. I added a SliderDrawer in Page then after I added codes as follows. But this codes not working in OnShow() event. How can I do this? Maybe I can do with write a lot of code. But I want to do without writing a lot of code.
function Page1_Self_OnShow() {
Pages.Page1.SliderDrawer1.show();
}
This is a known issue for Android, it will be fixed.But you can solve the problem until the bug is fixed as follows:
function Page1_Self_OnShow() {
var timeoutID = setTimeout(function () {
setHello();
}, 200);
function setHello() {
Pages.Page1.SliderDrawer1.show();
}
function cancelHello() {
clearTimeout(timeoutID);
}
}