Skip to content

Feat: Add OneSignal push provider adapter (#7726) - #131

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

Feat: Add OneSignal push provider adapter (#7726)#131
deepshekhardas wants to merge 1 commit into
utopia-php:mainfrom
deepshekhardas:feat/7726-onesignal-adapter

Conversation

@deepshekhardas

Copy link
Copy Markdown

No description provided.

@greptile-apps

greptile-appsBot commented Jun 17, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a new OneSignal push notification adapter implementing the shared PushAdapter contract. The adapter translates a Push message into a OneSignal notification payload and handles success/error responses.

  • The authorization header uses Basic instead of OneSignal's required Key scheme, causing every API request to fail with 401 Unauthorized.
  • The adapter targets the deprecated onesignal.com/api/v1/notifications endpoint and the deprecated include_player_ids field; the current OneSignal API uses api.onesignal.com/notifications with include_subscription_ids.
  • content_available is hardcoded to true regardless of whether the caller passes false, silently enabling background push when it should not be.

Confidence Score: 2/5

  • Not ready to merge — the adapter cannot send any notification in its current state.
  • The wrong authorization scheme (Basic instead of Key) means every request to OneSignal returns 401 before a single notification is delivered. The deprecated API endpoint and targeting field compound the problem. These two issues together make the adapter completely non-functional out of the box, and they affect every code path through process().
  • src/Utopia/Messaging/Adapter/Push/OneSignal.php — the authorization header, API URL, and subscriber-targeting field all need to be corrected before the adapter can send any notification.

Important Files Changed

FilenameOverview
src/Utopia/Messaging/Adapter/Push/OneSignal.phpNew OneSignal push adapter with several correctness issues: wrong authorization scheme (Basic instead of Key) causes every API call to fail with 401, the deprecated v1 endpoint and include_player_ids field are used instead of the current api.onesignal.com endpoint and include_subscription_ids, content_available is hardcoded to true even when the caller passes false, and iOS sound values have .wav appended unconditionally (corrupting names like default or already-qualified filenames).

Reviews (6): Last reviewed commit: "fix: add parent constructor, fix deliver..." | Re-trigger Greptile

Comment threadsrc/Utopia/Messaging/Adapter/Push/OneSignal.php
Comment threadsrc/Utopia/Messaging/Adapter/Push/OneSignal.php
Comment threadsrc/Utopia/Messaging/Adapter/Push/OneSignal.php
Comment threadsrc/Utopia/Messaging/Adapter/Push/OneSignal.php
Comment on lines +65 to +68
if (!\is_null($message->getSound())) {
$payload['android_sound'] = $message->getSound();
$payload['ios_sound'] = $message->getSound() . '.wav';
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2Do not rewrite sounds

Other push adapters pass the message sound through unchanged, and callers may pass values like default or an already-qualified filename. Appending .wav here changes default to default.wav and chime.wav to chime.wav.wav, which can make iOS use the wrong sound or no custom sound at all.

Suggested change
if (!\is_null($message->getSound())) {
$payload['android_sound'] = $message->getSound();
$payload['ios_sound'] = $message->getSound() . '.wav';
}
if (!\is_null($message->getSound())) {
$payload['android_sound'] = $message->getSound();
$payload['ios_sound'] = $message->getSound();
}

Comment threadsrc/Utopia/Messaging/Adapter/Push/OneSignal.php
Comment threadsrc/Utopia/Messaging/Adapter/Push/OneSignal.php Outdated
Comment on lines +84 to +86
if (!\is_null($message->getContentAvailable())) {
$payload['content_available'] = true;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1content_available condition inverts intent when explicitly set to false

The guard !\is_null($message->getContentAvailable()) is true for both true and false. If a caller explicitly constructs Push with contentAvailable: false, the adapter still writes 'content_available' => true into the payload, silently enabling silent/background push on OneSignal devices when the caller's intent was the opposite. The fix is to check the boolean value directly: if ($message->getContentAvailable()).

@deepshekhardas

Copy link
Copy Markdown
Author

Following up - OneSignal push adapter. Ready for review.

…h fields (icon, color, tag, contentAvailable, priority)
(cherry picked from commit dc4e0f3)
Sign up for freeto 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

@deepshekhardas