Push notifications to iPhone, Android and websites

sendvia sends push notifications straight to Apple, Google and the browser push services, signed with keys you upload once. The API key that sends your email also registers devices and sends to them. Push is a paid add-on to Premium, with 100,000 deliveries a month.

Last reviewed:

Can sendvia send push notifications?

Yes, to iPhone and iPad apps, Android apps and websites, from the same API key that sends your email. Push is a paid add-on to the Premium plan.

What each platform needs, and where its push token comes from.
PlatformYou uploadThe token isNotes
iPhone and iPad appsA .p8 key, Key ID, Team ID and bundle IDThe device token from Apple, as hexRegister with "environment": "sandbox" for builds run from Xcode, production for everything else
Android appsThe Firebase service account JSON fileThe registration token from Firebase Cloud MessagingNeeds the Firebase Cloud Messaging API turned on in the project
WebsitesNothing; sendvia generates the keysThe browser's push subscription objectChrome, Edge, Firefox and Safari. On iPhone and iPad, only for a site added to the home screen, on iOS 16.4 or later

Do I need Firebase to send push notifications to an iPhone?

No. sendvia talks to Apple's push service directly with the .p8 key from your Apple developer account, so an iPhone app needs no Firebase code. Firebase is only needed for Android apps. If your iPhone app already gets its push tokens from Firebase, register those as "provider": "google" instead, and Firebase hands them on to Apple with the Apple key you gave Firebase.

Can I send push notifications to a website without an app?

Yes. Visitors who allow notifications in Chrome, Edge, Firefox or Safari get them while their browser is running, even with your site closed. On iPhone and iPad, Apple only allows it for a site added to the home screen, on iOS 16.4 or later.

The website needs one file on its own domain, sendvia-push-sw.js, the small service worker that shows each notification and opens its link when clicked. It has no fetch handler, so it never touches how your pages load. sendvia generates the signing keys the browsers check, or you import a pair you already use, and the dashboard gives you the few lines of script that ask the visitor for permission.

How push works on sendvia

There are three parts, and only the last two are code.

  1. Upload your keys once. In the dashboard, an iPhone app needs the .p8 key from your Apple developer account plus its Key ID, Team ID and bundle ID. An Android app needs the service account JSON file from Firebase. A website needs nothing uploaded. Each key is checked against Apple or Google as you save it, so a typo shows up then rather than on your first send.
  2. Register each device. When your app or site gets a push token, it hands it to your own server, and your server passes it to POST /v1/push/devices with your user ID for that person. The API key stays on your server; an app should never carry it.
  3. Send to a person. POST /v1/push/send with that same user ID reaches every active device they have registered, iPhone, Android and browser alike, in one request.

sendvia calls Apple, Google and the browser push services itself, so there is no third party in between holding a copy of your device list.

Registering a device

Pass the token with "provider": "apple" or "google", or the whole subscription with "provider": "web". user_id is your own identifier for the person, up to 255 characters; sendvia never interprets it.

curl -X POST https://api.sendvia.io/v1/push/devices \
  -H "Authorization: Bearer sv_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "apple",
    "token":    "a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f60718293a4b5c6d7e8f90",
    "user_id":  "42"
  }'

A website sends what the browser's pushManager.subscribe() returned, as is:

{
  "provider": "web",
  "user_id":  "42",
  "subscription": {
    "endpoint": "https://fcm.googleapis.com/fcm/send/dX8aBcDeFgH...",
    "keys": { "p256dh": "BNcRdreALRFX...", "auth": "tBHItJI5svbpez7KI4CCXg" }
  }
}

Registering the same token again is safe, and is how you should handle an app launch: it refreshes the device and brings it back to active if it had been marked dead. To forget a device at logout, DELETE /v1/push/devices with {"token": "..."}.

Sending a push notification

curl -X POST https://api.sendvia.io/v1/push/send \
  -H "Authorization: Bearer sv_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "42",
    "title":   "Your order has shipped",
    "body":    "It should arrive on Thursday. Tap to track it.",
    "url":     "/orders/1234",
    "data":    { "order_id": "1234" },
    "tag":     "shipping"
  }'

Target either user_id (one, or a list of up to 100) or device_id (one, or a list of up to 500), never both. The response has one entry per device:

{
  "success": true,
  "total": 2, "sent": 2, "failed": 0, "invalid": 0,
  "results": [
    {"device_id": 17, "provider": "apple", "user_id": "42", "status": "sent", "log_id": 9001},
    {"device_id": 52, "provider": "web",   "user_id": "42", "status": "sent", "log_id": 9002}
  ]
}

The HTTP status follows the same rule as a multi-recipient email send: 200 when every device was reached, 207 when some were and some were not, 502 when none were. Send an Idempotency-Key header and a retry within 24 hours returns the original response instead of a second notification. Leave out title and body and send data on its own for a silent push that wakes an app without showing anything; websites cannot receive those, because browsers require every push to show a notification.

What can a notification show?

Every option goes in the same send request, and each platform ignores what is not for it, so one request can carry the lot. These drawings are approximate; each operating system draws its own.

iPhone
Y
Your appnow
Your order has shipped
Order 1234
It should arrive on Thursday. Tap to track it.
Android app
Your app· now
Your order has shipped
It should arrive on Thursday. Tap to track it.
Desktop browser
Y
Your order has shipped
It should arrive on Thursday. Tap to track it.
yoursite.com
Track parcelView order
Which options each platform shows. Where support is partial, the cell says how.
OptionFieldWebsitesiPhoneAndroid app
Title and texttitle, bodyYesYesYes
SubtitlesubtitleNoYesNo
Iconicon, android_iconYesAlways the app iconSmall icon from the app
Accent colourcolorNoNoYes
Small badge iconbadge_iconAndroid browsers onlyNoNo
Large imageimageChrome and EdgeNeeds an app extensionYes
Buttonsactions, categoryUp to 2, Chrome and EdgeDefined in the appDefined in the app
Link opened on clickurlYesSend it in dataSend it in data
Number on the app iconbadgeHome screen appsYesLauncher dependent
Group or replacegroup, collapse_keyReplace onlyYesReplace only
Interruption levelinterruption_levelNoYesNo
Stay on screenrequire_interaction, stickyChrome and EdgeNoYes
Sound and vibrationsound, vibrateSilent or vibrateYesYes
Channel and lock screenchannel_id, visibilityNoNoYes

A website can also set a default icon, badge icon and click-through link once in the dashboard, so a send only names them when it wants something different. Critical alerts on iPhone, the ones that sound through silent mode, need an entitlement Apple only grants to apps such as health, safety and security ones; without it the notification plays as an ordinary one.

What happens when an app is uninstalled?

Apple, Google and the browsers say so the next time you send to that device. sendvia marks the device invalid with the reason, stops sending to it, and deletes it 30 days later, the same way a hard bounce lands on the email blocklist. If the person reinstalls, your server registers the new token and it starts receiving again. The dashboard shows every device, its status and the last push it was sent, and a test button that sends one to it.

How much do push notifications cost on sendvia?

Push is a paid add-on, not part of the free plan. It sits on top of Premium ($19 a month) and is not self-serve: once you are on Premium, email [email protected] to have it switched on. Until then every push endpoint returns a 403. Billing in the dashboard shows whether it is enabled.

The add-on includes 100,000 deliveries a month, and one delivery is one device a notification is handed to. Sending to someone with a phone and a laptop uses two. The count resets on the 1st, and it is checked before anything goes out: a send that would cross the allowance is refused whole with a 429 rather than reaching some devices and not others. Apple, Google and the browsers do not charge per notification, so there is no second bill the way Amazon bills for email.

What does sendvia do with my Apple and Google keys?

They are encrypted with AES-256-GCM before they are stored, and only decrypted to sign requests to Apple and Google. The private key is never shown again after upload, and removing it in the dashboard deletes it. A website's private signing key is stored the same way.

Limits

The full request and response reference for all six push endpoints is in the API reference.