Skip to content

feat: Add OneSignal Push Notification Adapter (#7726)#5

Open
deepshekhardas wants to merge 1 commit into
mainfrom
feat/7726-onesignal-adapter
Open

feat: Add OneSignal Push Notification Adapter (#7726)#5
deepshekhardas wants to merge 1 commit into
mainfrom
feat/7726-onesignal-adapter

Conversation

@deepshekhardas
Copy link
Copy Markdown
Owner

@deepshekhardas deepshekhardas commented Apr 11, 2026

This PR adds support for OneSignal push notification adapter.

Changes:

  • Implements OneSignal API integration for push notifications
  • Supports device targeting and segmentation
  • Follows existing adapter patterns

Summary by cubic

Add a OneSignal push notification adapter to send notifications via OneSignal with device targeting by player IDs. Includes tests and follows the existing push adapter contract.

  • New Features
    • Integrates with OneSignal REST API at https://onesignal.com/api/v1/notifications using app_id and Authorization: Basic.
    • Maps message fields: title/bodyheadings/contents, data, actionurl, imagebig_picture/ios_attachments, soundandroid_sound/ios_sound, badgeios_badgeType/ios_badgeCount.
    • Targets devices via include_player_ids; supports up to 2000 recipients per request.
    • Reports per-recipient delivery and error details using the standard Response.

Written for commit 3fdb82d. Summary will update on new commits.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/Messaging/Adapter/Push/OneSignalTest.php">

<violation number="1" location="tests/Messaging/Adapter/Push/OneSignalTest.php:13">
P1: Guard this test when OneSignal credentials are missing; otherwise it will fail in CI because the workflow does not provide any `ONESIGNAL_*` env vars.</violation>
</file>

<file name="src/Utopia/Messaging/Adapter/Push/OneSignal.php">

<violation number="1" location="src/Utopia/Messaging/Adapter/Push/OneSignal.php:87">
P2: `deliveredTo` is undercounted for successful multi-recipient sends because this only increments the counter once.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

{
parent::setUp();

$appId = \getenv('ONESIGNAL_APP_ID');
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Guard this test when OneSignal credentials are missing; otherwise it will fail in CI because the workflow does not provide any ONESIGNAL_* env vars.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/Messaging/Adapter/Push/OneSignalTest.php, line 13:

<comment>Guard this test when OneSignal credentials are missing; otherwise it will fail in CI because the workflow does not provide any `ONESIGNAL_*` env vars.</comment>

<file context>
@@ -0,0 +1,23 @@
+    {
+        parent::setUp();
+
+        $appId = \getenv('ONESIGNAL_APP_ID');
+        $apiKey = \getenv('ONESIGNAL_API_KEY');
+
</file context>
Fix with Cubic

$response = new Response($this->getType());

if ($results['statusCode'] >= 200 && $results['statusCode'] < 300) {
$response->incrementDeliveredTo(\count($message->getTo()));
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: deliveredTo is undercounted for successful multi-recipient sends because this only increments the counter once.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/Utopia/Messaging/Adapter/Push/OneSignal.php, line 87:

<comment>`deliveredTo` is undercounted for successful multi-recipient sends because this only increments the counter once.</comment>

<file context>
@@ -0,0 +1,99 @@
+        $response = new Response($this->getType());
+
+        if ($results['statusCode'] >= 200 && $results['statusCode'] < 300) {
+            $response->incrementDeliveredTo(\count($message->getTo()));
+            foreach ($message->getTo() as $to) {
+                $response->addResult($to);
</file context>
Fix with Cubic

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

Successfully merging this pull request may close these issues.

1 participant