paystory-de / thermal-printer-cordova-plugin

Cordova wrapper for ESC/POS Thermal Printer library
Apache License 2.0
50 stars 39 forks source link

App closes at printer check with Ionic 6 (Android 12 & API 31) #32

Closed nextqs closed 1 year ago

nextqs commented 2 years ago

https://github.com/paystory-de/thermal-printer-cordova-plugin/blob/81cae42d3d3746fb577c030b0516875c88ee8116/src/android/ThermalPrinterCordovaPlugin.java#L93

When the function requestUSBPermissions() is called in Android 12 - API 31 the app Crashes and close with the follow log:

E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-1
    Process: xxxx.xxxxx.xxxx, PID: 3490
    java.lang.IllegalArgumentException: com.nextqs.app: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
        at android.app.PendingIntent.checkFlags(PendingIntent.java:382)
        at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:673)
        at android.app.PendingIntent.getBroadcast(PendingIntent.java:660)
        at de.paystory.thermal_printer.ThermalPrinterCordovaPlugin.requestUSBPermissions(ThermalPrinterCordovaPlugin.java:9😎
        at de.paystory.thermal_printer.ThermalPrinterCordovaPlugin.lambda$execute$0$de-paystory-thermal_printer-ThermalPrinterCordovaPlugin(ThermalPrinterCordovaPlugin.java:60)
        at de.paystory.thermal_printer.ThermalPrinterCordovaPlugin$$ExternalSyntheticLambda0.run(Unknown Source:😎
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:920)
patrickbussmann commented 1 year ago

Merged. Thank you for your work @nextqs 👍

jmdraj commented 2 months ago

i don't get the solution of the problem please exaplain