I have problem with ionic native plugin for printing ionic 4 - ionic-framework

I have a problem with this code when I run in the android device also ios I have the same problem
TypeError: Printer.getPlugin(...).check is not a function
at vendor.js:79303
at vendor.js:78443
at new ZoneAwarePromise (polyfills.js:3272)
at tryNativePromise (vendor.js:78442)
at getPromise (vendor.js:78463)
at vendor.js:79301
at Printer.push../node_modules/#ionic-native/printer/ngx/index.js.Printer.check (vendor.js:79308)
at Printer.push../node_modules/#ionic-native/printer/ngx/index.js.Printer.isAvailable (vendor.js:79294)
at SaleInfoPage.push../src/app/paenter code herege/sale-info/sale-info.page.ts.SaleInfoPage.print (main.js:1037)
at Object.eval [as handleEvent] (SaleInfoPage.html:54)
ionic info
Ionic:
Ionic CLI : 5.2.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : #ionic/angular 4.6.0
#angular-devkit/build-angular : 0.13.9
#angular-devkit/schematics : 7.3.9
#angular/cli : 7.3.9
#ionic/angular-toolkit : 1.5.1
Cordova:
Cordova CLI : 8.0.0
Cordova Platforms : android 8.0.0, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 9 other plugins)
Utility:
cordova-res : 0.5.0 (update available: 0.5.2)
native-run : 0.2.6 (update available: 0.2.7)
System:
Android SDK Tools : 26.1.1 (/Users/shahab/Library/Android/sdk/)
ios-deploy : 2.0.0
NodeJS : v8.11.3 (/usr/local/bin/node)
npm : 5.6.0
OS : macOS Mojave
Xcode : Xcode 10.2.1 Build version 10E
code in function
print()
{
this.printer.isAvailable().then(function(){
this.printer.print("https://www.techiediaries.com").then(function(){
alert("printing done successfully !");
},function(){
alert("Error while printing !");
});
}, function(e){
console.log(e);
alert('Error : printing is unavailable on your device ');
});
}

I solved my problem by installing this plugin with the same library
isiigoteam/cordova-plugin-printer

Related

postMessage() in iframe fails, because `document.referrer` returns empty string in iOS

I’m having a problem where a vendor’s javascript is throwing an error because document.referrer returns an empty string as a parameter being sent to postMessage().
Ionic:
Ionic CLI : 5.4.16
(/usr/local/lib/node_modules/ionic)
Ionic Framework :
#ionic/angular 6.0.14 #angular-devkit/build-angular : 12.2.17
#angular-devkit/schematics : 12.2.17 #angular/cli
: 12.2.17 #ionic/angular-toolkit : 4.0.0
Capacitor:
Capacitor CLI : 3.4.3 #capacitor/core : 3.4.3
Utility:
cordova-res : 0.15.4 native-run (update
available: 1.6.0) : 1.5.0
System:
NodeJS : v14.18.1 (/usr/local/bin/node) npm : 6.14.15 OS
: macOS Monterey

Capacitor - Uncaught TypeError: cap.[some_function] is not a function

I just upgraded capacitor to 3.2.x and when I try to build my Ionic project, almost no capacitor function seems to work. For example, I get errors like:
Uncaught TypeError: cap.nativeCallback is not a function
...
Uncaught TypeError: Capacitor.createEvent is not a function
...
package com.getcapacitor.annotation does not exist
Here's my Ionic Info:
Ionic:
Ionic CLI : 6.17.1 (/usr/local/lib/node_modules/#ionic/cli)
Ionic Framework : #ionic/angular 5.5.2
#angular-devkit/build-angular : 0.1000.8
#angular-devkit/schematics : 10.0.8
#angular/cli : 10.0.8
#ionic/angular-toolkit : 2.3.3
Capacitor:
Capacitor CLI : 3.2.3
#capacitor/android : 3.0.0-beta.3
#capacitor/core : 3.2.3
#capacitor/ios : not installed
Cordova:
Cordova CLI : 10.0.0
Cordova Platforms : android 9.1.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 9 other plugins)
Utility:
cordova-res : 0.15.3
native-run : 1.4.1
System:
Android SDK Tools : 26.1.1 (/home/che-azeh/Android/Sdk)
NodeJS : v12.21.0 (/usr/bin/node)
npm : 7.5.2
OS : Linux 5.11
Here was the problem: if you look at the capacitor section under my Ionic Info, you'd notice an incosistency between Capacitor CLI, #capaciotr/core and #capacitor/android:
Capacitor:
Capacitor CLI : 3.2.3
#capacitor/android : 3.0.0-beta.3
#capacitor/core : 3.2.3
So what I did was upgrade all 3 to their latest versions:
npm install #capacitor/cli#latest #capacitor/core#latest
npm install #capacitor/android#latest
Now, it looks ike:
Capacitor:
Capacitor CLI : 3.2.3
#capacitor/android : 3.2.3
#capacitor/core : 3.2.3
Finally, I remove the Android folder created by capacitor (rm -R ./android), reinitialize capacitor (npx cap init) rebuild ionic project (ionic build android) and then npx cap add android.
And solved! Zero errors!

Ionic 4: How to add zoom in and out using native qr scanner?

How can I implement zoom functionality in a native qr scanner? I tried installing the camera preview plugin but it keeps crashing the app. The new versions probably do not support it. My project version:
Ionic:
Ionic CLI : 5.2.5(C:\Users\Ivo\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework :
#ionic/angular : 4.11.5
#angular-devkit/build-angular : 0.801.3
#angular-devkit/schematics : 8.1.3
#angular/cli : 8.1.3
#ionic/angular-toolkit : 2.1.1
Cordova:
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : not available
Cordova Plugins : not available
Utility:
cordova-res : 0.8.1
native-run : 0.2.9
System:
Android SDK Tools : 26.1.1 (C:\Users\Ivo\AppData\Local\Android\Sdk)
NodeJS : v10.11.0 (C:\Program Files\nodejs\node.exe)
npm : 6.9.0
OS : Windows 10
I have tried so far:
to install camera preview plugin but it is not supported by this ionic version
searched for a QRScanner method, but wasn't able to find one. Found methods only for flashlight and rotating camera.

Ionic 4. How change header background color on old android versions

I tried to use css variables for this
ion-toolbar {
--background: #{$backgroundColor3};
--min-height: #{$spacing * 5};
}
All works correct in latest chrome and on android 8. But on adnroid 5 with chrome 40.* it is not worked.
I found that minimal android version for Ionic is 4.4 docs
>ionic info
Ionic:
Ionic CLI : 5.0.1
Ionic Framework : #ionic/angular 4.4.2
#angular-devkit/build-angular : 0.13.9
#angular-devkit/schematics : 7.3.9
#angular/cli : 7.3.9
#ionic/angular-toolkit : 1.5.1
Cordova:
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : android 8.0.0, ios 5.0.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.0, (and 9 other plugins)
Utility:
cordova-res : 0.3.0
native-run : 0.2.5
System:
Android SDK Tools : 26.1.1 (C:\Android)
NodeJS : v11.14.0 (C:\Program Files\nodejs\node.exe)
npm : 6.9.0
OS : Windows 10
Background is only one problem with styles:
Screenshot with issues from android 5
Normal screenshot
You need to be use add in global or page .scss file
--background: var(--ion-color-primary);
Here your answare.

Ionic 4 / RxJs - ERROR TypeError: Invalid event target

I'm trying to get the event from an input field but the following error occurs (same error for ngAfterViewInit / ionViewDidEnter):
ERROR TypeError: Invalid event target
at setupSubscription (fromEvent.js:50)
at Observable._subscribe (fromEvent.js:24)
at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:42)
at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:28)
at MapOperator.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapOperator.call (map.js:18)
at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:23)
at PeoplePage.push../src/app/people/people.page.ts.PeoplePage.ionViewDidEnter (people.page.ts:88)
at HTMLElement.handler (angular-delegate.js:101)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:3811)
people.page.ts
import {concat, fromEvent, Observable, of, pipe} from 'rxjs';
#ViewChild('searchInput') searchInput: ElementRef;
ionViewDidEnter() {
fromEvent<any>(this.searchInput.nativeElement, 'keyup')
.pipe(
map(ev => ev.target.value)
)
.subscribe(console.log); // <--- The error occurs here.
people.page.html
<ion-input placeholder="Name" #searchInput> </ion-input>
Ionic:
ionic (Ionic CLI) : 4.5.0
Ionic Framework : #ionic/angular 4.0.0-beta.19
#angular-devkit/build-angular : 0.7.5
#angular-devkit/schematics : 0.7.5
#angular/cli : 6.1.5
#ionic/angular-toolkit : not installed
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib#8.1.1)
Cordova Platforms : android 7.1.2
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.1, (and 11 other plugins)
System:
Android SDK Tools : 26.1.1
NodeJS : v11.5.0
npm : 6.5.0
OS : Linux 4.15