Skip to content

Commit 2ad2500

Browse files
authored
Merge pull request #1679 from appwrite/blog-push-notification-announcement
Blog: Add push notification announcement
2 parents ff7b95b + 046fa08 commit 2ad2500

File tree

4 files changed

+241
-0
lines changed

4 files changed

+241
-0
lines changed
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
---
2+
layout: post
3+
title: Announcing new features for Push Notifications
4+
description: 'Appwrite Messaging now supports background updates, critical alerts, and priority controls for push notifications.'
5+
date: 2025-01-22
6+
cover: /images/blog/announcing-new-push-notifications-features/cover.png
7+
timeToRead: 5
8+
author: jake-barnby
9+
category: product
10+
callToAction: true
11+
---
12+
13+
We're excited to introduce new additions to Appwrite Messaging that give you greater control over how you send and handle push notifications in your app.
14+
The push notification API now affords you finer control over both how and when your notifications are delivered.
15+
You can run background updates silently, send critical alerts that bypass Do Not Disturb, and manage delivery priorities.
16+
These changes enable you to handle common scenarios - such as data syncs, urgent alerts, and battery-conscious updates more effectively.
17+
18+
Here's a quick overview of the new features:
19+
20+
# Background updates (iOS)
21+
22+
We're now supporting Apple's background notifications through the `contentAvailable` parameter. This lets your iOS app process updates in the background without displaying notifications to users. Background notifications are useful for data syncs, content updates, and state changes that don't require user interaction.
23+
24+
When you set `contentAvailable`, your app wakes up in the background to handle the notification payload. This works well for messaging apps that need to fetch new messages, news apps refreshing content, or any app that needs to update data periodically. Since no UI is shown to users during background updates, you can omit both the title and body.
25+
26+
A few things to keep in mind when using background notifications:
27+
28+
- You'll need to configure your app to handle background processing using [Background Modes](https://developer.apple.com/documentation/xcode/configuring-background-execution-modes) in Xcode.
29+
- Set the notification priority to normal to ensure proper background delivery.
30+
- Apple limits background notifications to about 2-3 per hour to preserve battery life.
31+
- For Android users, you can achieve similar functionality by sending a data-only notification (just omit the title and body).
32+
33+
To implement background notifications, set `contentAvailable` to true and handle the [application:didReceiveRemoteNotification:fetchCompletionHandler:](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623013-application) method in your app.
34+
35+
# Critical alerts (iOS)
36+
37+
Sometimes, users need to see a notification even when their phone is on **Do Not Disturb**. The new `critical` parameter attempts to mark the notification as critical, which can bypass silent and do not disturb settings when approved. To use critical alerts, you'll need to request the critical alert entitlement from Apple through your developer account - just visit [Apple's developer portal](https://developer.apple.com/contact/request/notifications-critical-alerts-entitlement/) and fill out a brief form explaining your use case.
38+
39+
Critical alerts are essential for apps that handle time-sensitive or safety-related notifications, such as:
40+
41+
- Healthcare apps sending urgent medical alerts
42+
- Home security apps warning about break-ins
43+
- Connected device apps alerting about smoke or carbon monoxide detection
44+
- Emergency response apps sending evacuation notices
45+
- Financial apps warning about suspicious transactions
46+
47+
# Priority controls
48+
49+
You can now set notifications as either normal or high priority:
50+
51+
- **Normal priority:** The system delivers these at convenient times based on battery life and may group notifications together.
52+
- **High priority:** These go out right away - useful for time-sensitive updates.
53+
54+
# Other updates
55+
56+
- **Badge numbers (iOS):** Set a number to display on your app icon to show pending notifications. Set it to 0 to clear existing badges. Must be an integer.
57+
- **Data payload:** Both title and body are now optional fields. This gives you more flexibility, especially for background updates.
58+
59+
# Technical details
60+
61+
These new parameters work with our existing `createPush` and `updatePush` endpoints. We pass these parameters directly to the underlying push notification services (APNs for Apple and FCM for Android) - you just need to set the parameters you want.
62+
63+
Here are some examples to get you started:
64+
65+
## Example 1: Background update for fetching new messages
66+
67+
{% multicode %}
68+
69+
```dart
70+
Future result = await messaging.createPush(
71+
messageId: 'background-sync-1',
72+
title: null, // Optional for background updates
73+
body: null, // Optional for background updates
74+
topics: [], // Optional: Send to specific topics
75+
users: [], // Optional: Send to specific users
76+
targets: [], // Optional: Send to specific devices
77+
data: { // Optional: Custom data payload
78+
'type': 'message_sync',
79+
'lastSyncId': '123'
80+
},
81+
contentAvailable: true, // iOS background updates
82+
priority: 'normal', // Required for background updates
83+
);
84+
```
85+
86+
```js
87+
const result = await messaging.createPush(
88+
'background-sync-1', // messageId
89+
null, // title (optional for background updates)
90+
null, // body (optional for background updates)
91+
[], // topics (optional)
92+
[], // users (optional)
93+
[], // targets (optional)
94+
{
95+
// data (optional)
96+
type: 'message_sync',
97+
lastSyncId: '123'
98+
},
99+
null, // action (optional)
100+
null, // icon (optional)
101+
null, // sound (optional)
102+
null, // color (optional)
103+
null, // tag (optional)
104+
0, // badge (optional)
105+
true, // contentAvailable
106+
false, // critical (optional)
107+
'normal' // priority
108+
);
109+
```
110+
111+
{% /multicode %}
112+
113+
## Example 2: Critical alert for security breach
114+
115+
{% multicode %}
116+
117+
```dart
118+
Future result = await messaging.createPush(
119+
messageId: 'security-alert-1',
120+
title: 'Security Alert',
121+
body: 'Unusual activity detected at front door',
122+
topics: [], // Optional: Send to specific topics
123+
users: [], // Optional: Send to specific users
124+
targets: [], // Optional: Send to specific devices
125+
data: { // Optional: Custom data payload
126+
'type': 'security_alert',
127+
'deviceId': 'front_door_cam'
128+
},
129+
badge: 1, // Must be an integer
130+
critical: true, // iOS-only parameter
131+
priority: 'high', // High priority for critical alerts
132+
);
133+
```
134+
135+
```js
136+
const result = await messaging.createPush(
137+
'security-alert-1', // messageId
138+
'Security Alert', // title
139+
'Unusual activity detected at front door', // body
140+
[], // topics (optional)
141+
[], // users (optional)
142+
[], // targets (optional)
143+
{
144+
// data (optional)
145+
type: 'security_alert',
146+
deviceId: 'front_door_cam'
147+
},
148+
null, // action (optional)
149+
null, // icon (optional)
150+
null, // sound (optional)
151+
null, // color (optional)
152+
null, // tag (optional)
153+
1, // badge (must be an integer)
154+
false, // contentAvailable (optional)
155+
true, // critical (iOS-only)
156+
'high' // priority
157+
);
158+
```
159+
160+
{% /multicode %}
161+
162+
## Example 3: Normal notification for all platforms
163+
164+
{% multicode %}
165+
166+
```dart
167+
Future result = await messaging.createPush(
168+
messageId: 'chat-message-1',
169+
title: 'New Message',
170+
body: 'Sarah sent you a photo',
171+
topics: [], // Optional: Send to specific topics
172+
users: [], // Optional: Send to specific users
173+
targets: [], // Optional: Send to specific devices
174+
data: { // Optional: Custom data payload
175+
'chatId': '456',
176+
'messageType': 'photo'
177+
},
178+
badge: 3, // Integer for iOS, ignored on Android
179+
priority: 'normal', // Normal priority delivery
180+
);
181+
```
182+
183+
```js
184+
const result = await messaging.createPush(
185+
'chat-message-1', // messageId
186+
'New Message', // title
187+
'Sarah sent you a photo', // body
188+
[], // topics (optional)
189+
[], // users (optional)
190+
[], // targets (optional)
191+
{
192+
// data (optional)
193+
chatId: '456',
194+
messageType: 'photo'
195+
},
196+
null, // action (optional)
197+
null, // icon (optional)
198+
null, // sound (optional)
199+
null, // color (optional)
200+
null, // tag (optional)
201+
3, // badge (integer for iOS)
202+
false, // contentAvailable (optional)
203+
false, // critical (optional)
204+
'normal' // priority
205+
);
206+
```
207+
208+
{% /multicode %}
209+
210+
Each example shows different combinations of the new parameters based on common use cases. Note that some parameters like `critical` and `badge` are iOS-specific, while others work across platforms. You can mix and match these parameters based on your needs.
211+
212+
# Documentation and resources
213+
214+
- See the full implementation details in our [docs](https://appwrite.io/docs/products/messaging/messages)
215+
- Check out our best practices for sending [push notifications](https://appwrite.io/blog/post/push-notifications-best-practices)
216+
- Watch the [feature walkthrough](https://www.youtube.com/watch?v=QdDgPeuBZ1I)
217+
- Learn more about [Messaging](https://appwrite.io/products/messaging)
218+
219+
If you run into any issues or have questions about implementing these features, check the documentation or reach out to us through our support channels.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
layout: changelog
3+
title: "Push notifications: new delivery options and controls"
4+
date: 2025-01-22
5+
cover: /images/changelog/2025-01-22.png
6+
---
7+
8+
We've introduced new additions to Appwrite Messaging that give you greater control over how you send and handle push notifications in your apps.
9+
10+
## What's new
11+
12+
- **Background updates for iOS**: We've added support for silent background updates on iOS, with equivalent data-only notifications available for Android.
13+
- **Critical alerts for iOS**: You can now send notifications that bypass Do Not Disturb and notification settings.
14+
- **Priority controls for all platforms**: We've added options to manage delivery speed and battery usage across platforms.
15+
- **Badge numbers for iOS**: The badge parameter now accepts integers instead of strings for better type safety.
16+
- **Optional title and body for all platforms**: You can now send notifications without title and body for background and data-only updates.
17+
18+
These updates will help you build better notification experiences for your users. Try them out and share your feedback with us.
19+
20+
{% arrow_link href="/blog/post/announcing-new-push-notifications-features" %}
21+
Read the announcement to learn more
22+
{% /arrow_link %}
Loading
991 KB
Loading

0 commit comments

Comments
 (0)