ionic-team / capacitor

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

bug: pushNotificationReceived and pushNotificationActionPerformed events not triggering #3394

Closed shayanaijaz closed 3 years ago

shayanaijaz commented 3 years ago

Bug Report

Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 2.4.0 @capacitor/core: 2.4.0 @capacitor/android: 2.4.0 @capacitor/electron: 2.4.0 @capacitor/ios: 2.4.0

Installed Dependencies:

@capacitor/cli 2.4.0 @capacitor/ios 2.4.0 @capacitor/core 2.4.0 @capacitor/android 2.4.0 @capacitor/electron not installed

[success] Android looking great! 👌 Found 14 Capacitor plugins for ios: @mauron85/cordova-plugin-background-geolocation (3.1.0) cordova-plugin-actionsheet (2.3.3) cordova-plugin-advanced-http (2.5.1) cordova-plugin-androidx (2.0.0) cordova-plugin-androidx-adapter (1.1.1) cordova-plugin-background-fetch (6.1.1) cordova-plugin-dialogs (2.0.2) cordova-plugin-file (6.0.2) cordova-plugin-geolocation (4.0.2) cordova-plugin-screen-orientation (3.0.2) cordova.plugins.diagnostic (5.0.2) es6-promise-plugin (4.2.2) phonegap-plugin-multidex (1.0.0) uk.co.workingedge.phonegap.plugin.launchnavigator (5.0.4) [success] iOS looking great! 👌

Platform(s)

iOS

Current Behavior

The pushNotificationReceived and pushNotificationActionPerformed events are not triggered on iOS. I am using AWS Pinpoint therefore I am using APNS to get the token and using the pinpoint console to send test notifications. I am able to get a APNS token fine and successfully send a push through the Pinpoint console. On the phone I receive I receive a banner notification with the title and message I specified but the events mentioned above are not triggered and I see no console output.

Expected Behavior

On Android everything is working as expected, both the events fire and I am able to see the console outputs. Functionality should be the same for iOS.

Code Reproduction

async init() {

PushNotifications.addListener('registration', async (token: PushNotificationToken) => {
  console.log('TOKEN', token.value);
})

PushNotifications.addListener('registrationError', (error: any) => {
  console.log('error', error);
})

PushNotifications.addListener('pushNotificationReceived', (notification: PushNotification) => {
  console.log('notification', notification)
})

PushNotifications.addListener('pushNotificationActionPerformed', (notificationActionPerformed: PushNotificationActionPerformed) => {
  console.log('notification action performed', notificationActionPerformed.notification); 
})

const permResult = await PushNotifications.requestPermission();

if (permResult.granted) {
  await PushNotifications.register();
}

}

Other Technical Details

npm --version output: 6.13.4

node --version output: v12.14.1

pod --version output (iOS issues only): 1.9.3

Additional Context

jcesarmobile commented 3 years ago

@mauron85/cordova-plugin-background-geolocation has its own push notification handlers and prevent's Capacitor push from working

related https://github.com/ionic-team/capacitor/discussions/3357

StevieWag commented 3 years ago

@shayanaijaz and all the people who run in the same problem:

this workaround was helpful: https://github.com/mauron85/cordova-plugin-background-geolocation/issues/627#issuecomment-576582283

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.