ionic-team / capacitor-plugins

Official plugins for Capacitor ⚑️
517 stars 581 forks source link

Android: PushNotifications.register() Kill the app => (E/Capacitor: Serious error executing plugin java.lang.reflect.InvocationTargetException) #514

Closed xavierarpa closed 3 years ago

xavierarpa commented 3 years ago

Bug Report

Plugin(s)

   **@capacitor/push-notifications@1.0.0**

Capacitor Version

πŸ’Š   Capacitor Doctor  πŸ’Š 

Latest Dependencies:

  @capacitor/cli: 3.1.1
  @capacitor/core: 3.1.1
  @capacitor/android: 3.1.1
  @capacitor/ios: 3.1.1

Installed Dependencies:

  @capacitor/cli: 3.1.1
  @capacitor/core: 3.1.1
  @capacitor/android: 3.1.1
  @capacitor/ios: 3.0.0

[success] Android looking great! πŸ‘Œ

Platform(s)

Current Behavior

Each time when it do the check as expect and reach to the line PushNotification.register shows an error on the Android studio logcat (using the 'Run' app option with a USB mobile conection) and then close the app itself !

that occurs when it pass after PushNotifications.requestPermissions().then promise and checking if it is a 'granted' in the return response

Currently it was tested on this android devices:

  1. HUAWEI GRA-L09 (Close the App, tested in 'Run' app option and release)
  2. 5048Y_EEA (Close the App, tested in 'Run' app option and release)
  3. SM-G935F (First attemp 'stop working', the followings works right, tested only in release)

Expected Behavior

As the PushNotifications plugin works, it should start to do the request and then if is right to be registered (by the promise response with a 'granted' value) and next register it.

Other Technical Details

Possible details to know:

Additional Context

the following images shows the Android studio logcat within 'HUAWEI GRA-L09' device:

Captura de pantalla 2021-07-11 a las 12 36 20

And this is the Plugin, why so many things appears Deprecated? am I missing a new version and if is it, how can I update it?: Captura de pantalla 2021-07-11 a las 12 36 57

medida commented 3 years ago

@kingdox i've having the same issue - have you managed to solve it all?

medida commented 3 years ago

@kingdox i don;t know how / why but i have managed to get past this issue. I added import { Capacitor } from '@capacitor/core'; to my file and then checked if the platform was 'web' or not....

if (Capacitor.getPlatform() !== 'web') { PushNotifications.register(); }

But i removed the import and code - and it still works.. no idea why, but i have managed to get pas thtis which is great.

hope it helps you as well

xavierarpa commented 3 years ago

@kingdox i've having the same issue - have you managed to solve it all?

Yes I did it, in my case of desesperation just redo with npx cap init android in a new android project and adding one by one the things that knows it needs

My conclusion after that is it might be some libraries or another internal element who keeps obsoletes but it wasn't cleared at all after a update of a plugin or any other thing what Android manages πŸ€”

I'll close this thread, I'll hope that my response can solve your problem πŸš€

ionitron-bot[bot] commented 2 years ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.