ionic-team / capacitor

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

bug: Push notification with quickblox are not shown #2264

Closed youngdolphin closed 4 years ago

youngdolphin commented 4 years ago

npx cap doctor output:

Capacitor Doctor

Latest Dependencies:

@capacitor/cli: 1.4.0

@capacitor/core: 1.4.0

@capacitor/android: 1.4.0

@capacitor/ios: 1.4.0

Installed Dependencies:

@capacitor/ios not installed

@capacitor/cli 1.1.1

@capacitor/android 1.4.0

@capacitor/core 1.4.0

[success] Android looking great!

Affected Platform(s)

Current Behavior

I have a chat in my android app with quickblox. Quickblox should send a push notification (via FCM) when you send a message, but i only receive the notification if the app is in foreground with the PushNotification capacitor API:

PushNotifications.register();
PushNotifications.addListener('pushNotificationReceived',
     (notification: PushNotification) => {
          toastHelper.showToast('Push received');
          console.log('Push received: ' + JSON.stringify(notification));
    }
);

When the app is in background, I can see the console log when i receive a message from another user:

Msg: Push received: {"id":"0:12345678910%123456789abc","data":{"message_id":"12345678abcdefghi000","user_id":"1234567","message":"Test User: Hello","dialog_id":"123456789abcdefg"}}

but there is no push notifications, and when i reopen the app the toast message appears.

Expected Behavior

The push notification is shown.

Other Information

If I send notifications via FCM console i can see the push notification so i think the issue is not related to it or to some missing authorization.

sujeetulli commented 4 years ago

Same issue i'm facing in android, In iOS i'm able see notification...

jcesarmobile commented 4 years ago

This is the expected behaviour for data notifications, we don't have any logic to show them because data notifications can have any format that we can't know about. Try to use LocalNotifications plugin instead of Toast as Toast only works in foreground.

youngdolphin commented 4 years ago

@jcesarmobile Thanks for the reply, with LocalNotifications plugin now i can see notifications while app is in background. Do you please have any suggestion on how i can receive and create notifications even when the app is killed and is not in background?

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.