EddyVerbruggen / EddyVerbruggen/nativescript-printer

v2.0.0 crashes Android when using with a NativeScript 6.5.3 project

Open
#29 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
38
Forks
12
PR merge metrics
No merged PRs in 30d

Description

I added nativescript-printer to an existing 6.5.3 project and instantiation of a Printer object causes the Android application to crash.

Line 17 of printer.android.ts causes the application to crash:
`this.printManager = Utils.ad.getApplicationContext().getSystemService(android.content.Context.PRINT_SERVICE);`

The problem is in the import of Utils. Older versions of @nativescript/core don't have 'ad' in the definition of Utils. I'm hesitant to upgrade @nativescript/core because previous attempts at upgrading the application to NS 7 did not go well.

Changing the import to
`import * as utils from '@nativescript/core/utils/utils';`
and changing line 17 to
`this.printManager = utils.ad.getApplicationContext().getSystemService(android.content.Context.PRINT_SERVICE);`
fixes this issue.

I've made a PR to fix the issue.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.