ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
11.44k stars 977 forks source link

bug: PushNotifications.register is not a function (Android) #5656

Closed Houdhey closed 2 years ago

Houdhey commented 2 years ago

Bug Report

Capacitor Version


  @capacitor/cli 2.2.0

  @capacitor/android 2.2.0

  @capacitor/ios 2.4.2

  @capacitor/core 2.2.0

Platform(s)

Android

Current Behavior

Triggerring PushNotifications.register() for Android Device. Getting this error : PushNotifications.register is not a function

I don't want to upgrade Capacitor, our App is in production, and we can't take risks by migrating to another Capacitor version. I can't receive push notifications anymore on Android, and iOS. And when I add this method, Push works for iOS, but not for Android, because of this method having this error

Expected Behavior

Should work, and allow me to receive Push Notifications.

Code Reproduction

      if (permission.granted) {
        PushNotifications.addListener('registration', (registration) => {
          console.log('PUSH NOTIFICATIONS DEBUG - REGISTRATION ' + JSON.stringify(registration));
        });
        PushNotifications.register();
}
});

Other Technical Details

npm --version output: 8.5.0

node --version output: v16.14.2

jcesarmobile commented 2 years ago

Sorry, we no longer support Capacitor 2 except for security issues. Consider upgrading to Capacitor 3 https://capacitorjs.com/docs/updating/3-0

ionitron-bot[bot] commented 1 year 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 Capacitor, please create a new issue and ensure the template is fully filled out.