Skip to main content
This page is part of Example app: a full OneSignal integration, which follows one real app from end to end. The app is Clean Beans, a cleaning rota for shared homes, built with Expo (React Native) and a Supabase backend. Getting a push to arrive is the first step. This page covers the smaller decisions that make pushes trustworthy: never sending the same one twice, letting stale ones expire, and making each type behave in a way that suits it.

Never send the same reminder twice

Scheduled jobs get retried. A job can also be run twice by mistake. Without protection, each repeat sends another push. OneSignal’s idempotency_key solves this. If two requests carry the same key, the second is not sent. The key must be a UUID, and OneSignal remembers it for 30 days. A scheduled function has nowhere to keep a random key between runs, so Clean Beans derives the key from what the send is: its type, its recipient, and its date. The same send always produces the same key.
supabase/functions/_shared/idempotency.ts
For a batched send, the key covers the whole batch.
supabase/functions/send-cleaning-reminder/index.ts
Idempotency keys work on the Create message and Create custom events endpoints. Live Activity requests do not accept them. Those are identified by their activity_id instead.

Give each type of push its own behavior

A cleaning reminder that arrives two hours late is worse than no reminder. Kudos are nice to receive but never urgent. Clean Beans describes these differences once, in a set of delivery profiles, and spreads the right one into each request.
supabase/functions/_shared/delivery.ts
The member_lapsed profile in the type list belongs to a push sent from a Journey webhook, which this guide does not cover. What each setting does:
  • ttl is how long a push is held for a device that is offline. The cleaning reminder says “in 1 hour”, so it is dropped after an hour.
  • thread_id and android_group group related pushes together in the notification list.
  • ios_interruption_level controls how insistent a push is. time_sensitive can break through Focus modes. passive arrives silently.
  • ios_relevance_score ranks pushes in the iOS notification summary. Clean Beans keeps 1.0 for critical messages, and sends none.
App setup. iOS only honors time_sensitive if the app declares the capability.
app.json
A lesson learned: collapse_id. Clean Beans first gave the digest and the overdue reminder the same collapse_id, so the reminder would replace the digest. On iOS, a push that replaces one still in the notification list is swapped in place, with no banner and no sound. The reminder went unnoticed, which defeated its purpose, so the setting was removed. Use collapse_id only when a silent update is what you want, such as a live score.

Show a count on the app icon

The two task pushes set the app icon badge to the number in their heading.
supabase/functions/send-overdue-reminders/index.ts
The Clean Beans app icon with a badge count

The app icon badge shows how many tasks are overdue.

SetTo is used, not Increase, because the badge is a count of tasks and not a count of unread notifications. The afternoon reminder replaces the morning number.
The OneSignal SDK clears the badge automatically whenever the app is opened, so the app needs no code to reset it. A push that arrives while the app is open never shows its badge. Android has no numeric badge to set through the API.

Idempotent requests

How keys work and how long they last.

Interruption levels

Focus modes and the four levels.

Badges

Badge behavior on each platform.