Open girishk55 opened 4 years ago
I'm running into i think the same issue on Ionic4/5 + NodeJS : v13.12.0 + Xcode 11.4
TLDR; when i check
this.printer.isAvailable();
I'm getting:
[Error] ERROR – Error: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'this.printer')
I have removed plugin/platform re-added same, updated modules rebuilt ad nauseam Does anyone know the cause? Have a fix? or even a workaround?
For Thoroughness :
Environment:
Ionic:
Ionic CLI : 5.4.16 (/Users/Shared/Opt/.npm/lib/node_modules/ionic) Ionic Framework : @ionic/angular 4.11.10 @angular-devkit/build-angular : 0.801.3 @angular-devkit/schematics : 8.1.3 @angular/cli : 8.1.3 @ionic/angular-toolkit : 2.0.0
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1) Cordova Platforms : browser 6.0.0, ios 5.1.1 Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 10 other plugins)
Utility:
cordova-res : 0.11.0 native-run : not installed
System:
ios-sim : 8.0.2 NodeJS : v13.12.0 (/Users/Shared/Opt/bin/node) npm : 6.13.4 OS : macOS Catalina Xcode : Xcode 11.4 Build version 11E146
Project set up ran...
$ ionic capacitor add iOS $ ionic cordova prepare iOS
Plugin set up ran...
$ ionic cordova plugin add cordova-plugin-printer $ npm install @ionic-native/printer
Printer dir is present in Platforms:
In /package.json
"dependencies": { "@ionic-native/printer": "^5.23.0", "cordova-plugin-printer": "^0.8.0”, "cordova": { "plugins": { "cordova-plugin-whitelist": {}, }, "cordova-plugin-printer": {},
In: src/app/app.module.ts
import { Printer, PrintOptions } from '@ionic-native/printer/ngx’;
@NgModule({ providers: [ Printer,
In src/app/services/printer.service.ts
import { Printer, PrintOptions } from '@ionic-native/printer/ngx’;
constructor( private printer: Printer, private reporting: ScoreReportingService ) { }
In src/app/mod/results-print/results-print.page.ts
import { PrinterService } from '../../services/printer.service’;
constructor( private fb: FormBuilder, private printer: PrinterService ) { }
public printerWorks = this.printer.isAvailable();
ngOnInit() { cosole.log(printerWorks)
Getting the following error:
[Error] ERROR – Error: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'this.printer') ionic://localhost/main-es2015.js:1853:17 onInvoke@ionic://localhost/vendor-es2015.js:71868:39 run@ionic://localhost/polyfills-es2015.js:3130:49 ionic://localhost/polyfills-es2015.js:3861:39 onInvokeTask@ionic://localhost/vendor-es2015.js:71849:43 runTask@ionic://localhost/polyfills-es2015.js:3174:57 drainMicroTaskQueue@ionic://localhost/polyfills-es2015.js:3565:42 promiseReactionJob@[native code] Error: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'this.printer') ionic://localhost/main-es2015.js:1853:17 onInvoke@ionic://localhost/vendor-es2015.js:71868:39 run@ionic://localhost/polyfills-es2015.js:3130:49 ionic://localhost/polyfills-es2015.js:3861:39 onInvokeTask@ionic://localhost/vendor-es2015.js:71849:43 runTask@ionic://localhost/polyfills-es2015.js:3174:57 drainMicroTaskQueue@ionic://localhost/polyfills-es2015.js:3565:42 promiseReactionJob@[native code]resolvePromise — zone-evergreen.js:797(anonymous function) — zone-evergreen.js:862onInvokeTask — core.js:34182runTask — zone-evergreen.js:168drainMicroTaskQueue — zone-evergreen.js:559promiseReactionJob defaultErrorLogger (vendor-es2015.js:46777) handleError (vendor-es2015.js:46829) next (vendor-es2015.js:72582) (anonymous function) (vendor-es2015.js:68718) __tryOrUnsub (vendor-es2015.js:115058) next (vendor-es2015.js:114997) _next (vendor-es2015.js:114947) next (vendor-es2015.js:114924) next (vendor-es2015.js:114710) emit (vendor-es2015.js:68680) run (polyfills-es2015.js:3130) onHandleError (vendor-es2015.js:71904) runGuarded (polyfills-es2015.js:3143) (anonymous function) (polyfills-es2015.js:3669) drainMicroTaskQueue (polyfills-es2015.js:3572) promiseReactionJob
I am using this plugin in ionic. This plugin does not initialise on device ready when running the app on iOS simulator. Below are the logs:
2019-11-19 18:31:20.737102+0530 MyApp[18119:210865] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///Users/admin/Library/Developer/CoreSimulator/Devices/540A3F5A-E1FD-4DE0-9F0C-ED5447C0B073/data/Containers/Data/Application/B5DBB687-6B28-4BE6-AE70-A71D48617585/Library/Cookies/io.ionic.starter.binarycookies 2019-11-19 18:31:20.832741+0530 MyApp[18119:210865] Apache Cordova native platform version 5.0.1 is starting. 2019-11-19 18:31:20.833666+0530 MyApp[18119:210865] Multi-tasking -> Device: YES, App: YES 2019-11-19 18:31:20.847725+0530 MyApp[18119:210865] CDVWKWebViewEngine: trying to inject XHR polyfill 2019-11-19 18:31:20.901416+0530 MyApp[18119:210865] CDVWKWebViewEngine will reload WKWebView if required on resume 2019-11-19 18:31:20.901730+0530 MyApp[18119:210865] Using Ionic WKWebView 2019-11-19 18:31:20.902650+0530 MyApp[18119:210865] [CDVTimer][console] 0.136971ms 2019-11-19 18:31:20.902981+0530 MyApp[18119:210865] [CDVTimer][handleopenurl] 0.122905ms 2019-11-19 18:31:20.906301+0530 MyApp[18119:210865] [CDVTimer][intentandnavigationfilter] 3.158092ms 2019-11-19 18:31:20.906647+0530 MyApp[18119:210865] [CDVTimer][gesturehandler] 0.144005ms 2019-11-19 18:31:20.907067+0530 MyApp[18119:210865] CDVIonicKeyboard: resize mode 1 2019-11-19 18:31:20.908278+0530 MyApp[18119:210865] [CDVTimer][cdvionickeyboard] 1.435995ms 2019-11-19 18:31:20.916179+0530 MyApp[18119:210865] [CDVTimer][splashscreen] 7.696986ms 2019-11-19 18:31:20.921438+0530 MyApp[18119:210865] [CDVTimer][statusbar] 4.967093ms 2019-11-19 18:31:20.921658+0530 MyApp[18119:210865] [CDVTimer][TotalPluginStartup] 19.219995ms 2019-11-19 18:31:48.277976+0530 MyApp[18119:210865] Simulator user has requested new graphics quality: 100
The problem seems to be only with Ionic, if I try with Cordova project it works perfect. Below are my ionic code:
It always goes to error block on iOS platform and shows 'cordova_not_available' error. Works perfect on Android platform.
Please help me out to fix this issue. Thanks in advance.