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

[Bug]: Send Notification with invalid or not subscribed player IDs #810

Closed
2 of 3 tasks
Arhidev opened this issue Dec 20, 2023 · 5 comments
Closed
2 of 3 tasks

[Bug]: Send Notification with invalid or not subscribed player IDs #810

Arhidev opened this issue Dec 20, 2023 · 5 comments

Comments

@Arhidev
Copy link

Arhidev commented Dec 20, 2023

What happened?

How can we help?
Hello to you !
With older versions of onesignal, it was simple and efficient to send notifications with the following code:
(OneSignal.shared.postNotification(notification)

static void sendSimpleMessage({String msg, String playerId}) async { var notification = OSCreateNotification( playerIds: [playerId], content: msg, heading: "Cdou", buttons: [OSActionButton(text: "voir", id: "id1"),]); try { await OneSignal.shared.postNotification(notification) .then((value) => Constant.alertToast(msg: "Succés!", color: Colors.green)).catchError((er) {}); }catch (e) { // TODO } }

But currently impossible, or please tell me how to do it!
Thank you very much

Steps to reproduce?

flutter pub add onesignal_flutter

What did you expect to happen?

To be able to send notifications following the same process as OneSignal.shared.postNotification(notification)

OneSignal Flutter SDK version

onesignal_flutter: ^5.0.4

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@shepherd-l
Copy link
Contributor

Hello!

We removed postNotification because recommend using our API to send notifications rather than sending them on the device level due to the potential security issue of exposing another user's id on the device.

We have API documentation on how to send a notification here: https://documentation.onesignal.com/reference/create-notification

If this doesn’t work for your use case, could you explain what your use case is?

@aristidenx
Copy link

I also tried using the API, but with e.g. endpoint
'https://onesignal.com/api/v1/notifications'
When a player_id of "include_player_ids": [player_id_2, player_id_2], is invalid or [Not Subscribed] or inactive, sending notification to a set of users fails.

@shepherd-l
Copy link
Contributor

@aristidenx
Could you provide the exact server response you received?

@Arhidev
Copy link
Author

Arhidev commented Dec 22, 2023

An error like
unable to send notification player id not subscribed

@shepherd-l
Copy link
Contributor

@Arhidev
What response code did you receive? Could you please share the entire server response you got so we investigate the issue?

If some player_ids are invalid or not subscribed, the others should still receive it.
The response should be a 200
For example, this is the response I received and I do get a notification on the subscription that subscribed.

{
    "id": "SOME_NOTIFICATION_ID",
    "external_id": null,
    "errors": {
        "invalid_player_ids": [
            "abcde-9b44-472b-85c7-redacted"
        ]
    }
}

@nan-li nan-li changed the title [Bug]: Send Notification [Bug]: Send Notification with invalid or not subscribed player IDs Jan 30, 2024
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

4 participants