Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question]: How to handle the Silent Notification in release version 3.x.x? is there any guides or sample codes. #835

Open
1 task done
009topersky opened this issue Dec 26, 2022 · 3 comments

Comments

@009topersky
Copy link

How can we help?

Good day everyone!

We've been using OneSignal for quite some time and implemented it for several projects.
We migrated the version of OneSignal from 2.x.x into 3.x.x and it seems fine.

The problem is that we have some implementation in silent notification wherein there are no headings and contents.

To simulate the issue.

STEP 1:
We sent the data from the OneSignal REST API

POST: https://onesignal.com/api/v1/notifications

HEADERS:
Authorization: Bearer <ONESIGNAL_REST_API_KEY>

**PAYLOAD: **

{   
    "app_id": "ONESIGNAL_APP_ID",
     "huawei_msg_type": "data",
     "data": {"notificationContext": "timelog-break-out"},
     "content_available": true,
     "include_external_user_ids": ["Supervisor-external-id1"],
     "isAppInFocus": true
}

STEP 2:
In ionic 3 framework under the upon initialization of app based on the documentation
https://documentation.onesignal.com/docs/ionic-sdk-setup.

import OneSignal from 'onesignal-cordova-plugin';
...
constructor() {
    OneSignal.setAppId(environment.ONESIGNAL_APPID);
    
    // Actions for opening the push notification
    OneSignal.setNotificationOpenedHandler(function(notificationOpenedEvent) {
        console.log('setNotificationOpenedHandler:::', notificationOpenedEvent);
        const notif = notificationOpenedEvent.notification;
        notificationOpenedCallback(notif);
      });

    // Actions when receiving the notification in forebackground
     OneSignal.setNotificationWillShowInForegroundHandler(function(notificationReceivedEvent) {
        console.log('setNotificationWillShowInForegroundHandler:::', notificationReceivedEvent);
        const notif: any = notificationReceivedEvent.getNotification();
   
        notificationShowCallback(notif);
        notificationReceivedEvent.complete(notif);
      });
}
...

My goal is that the application should receive silent notifications even if the app is idle or in the background.

We already checked this documentations:
https://documentation.onesignal.com/docs/service-extensions#section-notification-extender-service
and
https://documentation.onesignal.com/docs/data-notifications

but there are no specific docs that pertain to the implementation of backgrounds/silent notifications.

Sample codes and implementations could help us solve the issue.

Thanks.
Have a nice day!

Code of Conduct

  • I agree to follow this project's Code of Conduct
@matheusssoares
Copy link

I have the same problem, any examples to help?

@anatoly-spb
Copy link

anatoly-spb commented Apr 5, 2023

I have proposed the following PR #876 to support data/background messages on Android

@anatoly-spb
Copy link

It seems to me we have to migrate to Firebase SDK from OneSignal SDK, because there are no one to maintain this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants