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]: Is Notification API working? #1916

Closed
1 task done
vknow360 opened this issue Nov 18, 2023 · 4 comments
Closed
1 task done

[question]: Is Notification API working? #1916

vknow360 opened this issue Nov 18, 2023 · 4 comments

Comments

@vknow360
Copy link

vknow360 commented Nov 18, 2023

How can we help?

I am unable to send push notification to Subscribed Users from API but notifications can be sent from dashboard.
Error I am getting:
{"id":"","errors":["All included players are not subscribed"]}

Code I used:

        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        JSONObject object = new JSONObject();
        object.put("app_id", "8c6cbe1c-****-****-****-c861915cbc4c");
        JSONArray array = new JSONArray();
        array.add("Active Users");
        object.put("included_segments", array);
        JSONObject object1 = new JSONObject();
        object1.put("en", "Hello World!");
        object.put("contents", object1);
        JSONObject object2 = new JSONObject();
        object2.put("en", "Hello!");
        object.put("headings", object2);
        System.out.println(object.toJSONString());
        RequestBody body = RequestBody.create(mediaType, object.toJSONString());
        Request request = (new Request.Builder()).url("https://onesignal.com/api/v1/notifications").post(body).addHeader("accept", "application/json").addHeader("Authorization", "Basic <API KEY>").addHeader("content-type", "application/json").build();
        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());

Code of Conduct

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

Hello @vknow360 thank you for your patience. Are you still having issues?

The "All Included Players are not subscribed" warning may be because the filter or segment you are targeting does not have any subscribed users to receive push notifications. Can you double check your Active Users segment to ensure you have users there?

Feel free to let us know if you are still having trouble!

@vknow360
Copy link
Author

vknow360 commented Nov 23, 2023

Yes, I am still facing the issue.
I can easily send notifications from the dashboard and they are getting delivered as well.
Only api has this issue.
Is there any possibility of an issue with the organisation/app config itself?

I have tested with 5.0.2 , 3 and 4.

@webquangnam
Copy link

Bạn có thể tìm thấy giải pháp tương tự tại đây
https://webquangnam.com/chia-se/flutter/onesignal-all-included-players-are-not-subscribed/

@vknow360
Copy link
Author

Bạn có thể tìm thấy giải pháp tương tự tại đây https://webquangnam.com/chia-se/flutter/onesignal-all-included-players-are-not-subscribed/

Thank you.
Your solution works.

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