From fc52c6a5e1766f1f7f520e63e464baa33de75bd8 Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Mon, 20 Jan 2025 17:32:01 +0000 Subject: [PATCH 1/4] Doc: add new push message parameters --- .../products/messaging/messages/+page.markdoc | 63 +++++++++++++++---- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/src/routes/docs/products/messaging/messages/+page.markdoc b/src/routes/docs/products/messaging/messages/+page.markdoc index dbfa7a7f11..7aac0df28d 100644 --- a/src/routes/docs/products/messaging/messages/+page.markdoc +++ b/src/routes/docs/products/messaging/messages/+page.markdoc @@ -152,6 +152,18 @@ Here are the different components that make up a message. * optional * Sets the number to display next to the app's icon, indicating the number of notifications or updates. Setting to 0 removes any existing badge. This is for Apple devices only. --- +* `contentAvailable` +* optional +* For iOS devices only. When set, wakes up the app in the background without showing a notification. Used to update app data remotely. Requires priority to be set to normal. **Note:** APNS may throttle if sending more than 2-3 background notifications per hour. For Android, similar functionality can be achieved by sending a data-only notification without title and body. +--- +* `critical` +* optional +* For iOS devices only. Marks the notification as critical to bypass silent and do not disturb settings. Requires the app to have the critical notification entitlement from Apple. +--- +* `priority` +* optional +* Sets notification priority to normal or high. Normal priority delivers at the most convenient time based on battery life and may group notifications. High priority delivers immediately. +--- * `draft` * optional * If the message is a draft, can be `true` or `false`. @@ -251,6 +263,9 @@ const message = await messaging.createPush( '[COLOR]', // color (optional) '[TAG]', // tag (optional) '[BADGE]', // badge (optional) + false, // contentAvailable (optional) + false, // critical (optional) + 'normal', // priority (optional) true, // draft (optional) '' // scheduledAt (optional) ); @@ -283,6 +298,9 @@ const message = await messaging.createPush( '[COLOR]', // color (optional) '[TAG]', // tag (optional) '[BADGE]', // badge (optional) + false, // contentAvailable (optional) + false, // critical (optional) + 'normal', // priority (optional) true, // draft (optional) '' // scheduledAt (optional) ); @@ -317,6 +335,9 @@ $result = $messaging->createPush( color: '[COLOR]', // optional tag: '[TAG]', // optional badge: '[BADGE]', // optional + contentAvailable: false, // optional + critical: false, // optional + priority: 'normal', // optional draft: true, // optional scheduledAt: '' // optional ); @@ -349,6 +370,9 @@ result = messaging.create_push( color = '[COLOR]', # optional tag = '[TAG]', # optional badge = '[BADGE]', # optional + content_available = False, # optional + critical = False, # optional + priority = 'normal', # optional draft = True, # optional scheduled_at = '' # optional ) @@ -379,6 +403,9 @@ response = messaging.create_push( color: '[COLOR]', # optional tag: '[TAG]', # optional badge: '[BADGE]', # optional + content_available: false, # optional + critical: false, # optional + priority: 'normal', # optional draft: true, # optional scheduled_at: '' # optional ) @@ -400,19 +427,23 @@ var messaging = new Messaging(client); Message result = await messaging.CreatePush( messageId: "[MESSAGE_ID]", title: "[TITLE]", - body: "[BODY]" - topics: new List {} // optional - users: new List {} // optional - targets: new List {} // optional - data: [object] // optional - action: "[ACTION]" // optional - icon: "[ICON]" // optional - sound: "[SOUND]" // optional - color: "[COLOR]" // optional - tag: "[TAG]" // optional - badge: "[BADGE]" // optional - draft: true // optional - scheduledAt: ""); // optional + body: "[BODY]" + topics: new List {}, // optional + users: new List {}, // optional + targets: new List {}, // optional + data: [object] // optional + action: "[ACTION]", // optional + icon: "[ICON]", // optional + sound: "[SOUND]", // optional + color: "[COLOR]", // optional + tag: "[TAG]", // optional + badge: "[BADGE]", // optional + contentAvailable: false, // optional + critical: false, // optional + priority: "normal", // optional + draft: true, // optional + scheduledAt: "" // optional +); ``` ```dart import 'package:dart_appwrite/dart_appwrite.dart'; @@ -443,6 +474,9 @@ void main() async { // Init SDK color: '[COLOR]', // optional tag: '[TAG]', // optional badge: '[BADGE]', // optional + content_available: false, // optional + critical: false, // optional + priority: 'normal', // optional draft: true, // optional scheduledAt: '', // optional ); @@ -555,6 +589,9 @@ let message = try await messaging.createPush( color: "[COLOR]", // optional tag: "[TAG]", // optional badge: "[BADGE]", // optional + content_available: false, // optional + critical: false, // optional + priority: "normal", // optional draft: true, // optional scheduledAt: "" // optional ) From 35945c9820d96aa4e435c732286a453945812ab5 Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Tue, 21 Jan 2025 10:53:43 +0000 Subject: [PATCH 2/4] Specify title, body as optional, badge as integer --- .../products/messaging/messages/+page.markdoc | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/routes/docs/products/messaging/messages/+page.markdoc b/src/routes/docs/products/messaging/messages/+page.markdoc index 7aac0df28d..ac240ae740 100644 --- a/src/routes/docs/products/messaging/messages/+page.markdoc +++ b/src/routes/docs/products/messaging/messages/+page.markdoc @@ -117,12 +117,12 @@ Here are the different components that make up a message. * The title of the push notification. This is the headline text that recipients see first. --- * `title` -* required -* The title of the push notification. This is the headline text that recipients see first. +* optional +* The title of the push notification. This is the headline text that recipients see first. Can be omitted for background notifications. --- * `body` -* required -* The main content or body of the push notification. Provides the details or message you want to convey. +* optional +* The main content or body of the push notification. Provides the details or message you want to convey. Can be omitted for background notifications. --- * `data` * optional @@ -150,7 +150,7 @@ Here are the different components that make up a message. --- * `badge` * optional -* Sets the number to display next to the app's icon, indicating the number of notifications or updates. Setting to 0 removes any existing badge. This is for Apple devices only. +* Sets the number to display next to the app's icon, indicating the number of notifications or updates. Setting to 0 removes any existing badge. Must be an integer. For Apple devices only. --- * `contentAvailable` * optional @@ -262,7 +262,7 @@ const message = await messaging.createPush( '[SOUND]', // sound (optional) '[COLOR]', // color (optional) '[TAG]', // tag (optional) - '[BADGE]', // badge (optional) + 1, // badge (optional) false, // contentAvailable (optional) false, // critical (optional) 'normal', // priority (optional) @@ -297,7 +297,7 @@ const message = await messaging.createPush( '[SOUND]', // sound (optional) '[COLOR]', // color (optional) '[TAG]', // tag (optional) - '[BADGE]', // badge (optional) + 1, // badge (optional) false, // contentAvailable (optional) false, // critical (optional) 'normal', // priority (optional) @@ -334,7 +334,7 @@ $result = $messaging->createPush( sound: '[SOUND]', // optional color: '[COLOR]', // optional tag: '[TAG]', // optional - badge: '[BADGE]', // optional + badge: 1, // optional contentAvailable: false, // optional critical: false, // optional priority: 'normal', // optional @@ -369,7 +369,7 @@ result = messaging.create_push( sound = '[SOUND]', # optional color = '[COLOR]', # optional tag = '[TAG]', # optional - badge = '[BADGE]', # optional + badge = 1, // optional content_available = False, # optional critical = False, # optional priority = 'normal', # optional @@ -437,7 +437,7 @@ Message result = await messaging.CreatePush( sound: "[SOUND]", // optional color: "[COLOR]", // optional tag: "[TAG]", // optional - badge: "[BADGE]", // optional + badge: 1, // optional contentAvailable: false, // optional critical: false, // optional priority: "normal", // optional @@ -473,7 +473,7 @@ void main() async { // Init SDK sound: '[SOUND]', // optional color: '[COLOR]', // optional tag: '[TAG]', // optional - badge: '[BADGE]', // optional + badge: 1, // optional content_available: false, // optional critical: false, // optional priority: 'normal', // optional @@ -514,7 +514,7 @@ messaging.createPush( "[SOUND]", // sound (optional) "[COLOR]", // color (optional) "[TAG]", // tag (optional) - "[BADGE]", // badge (optional) + 1, // badge (optional) true, // draft (optional) "" // scheduledAt (optional) new CoroutineCallback<>((result, error) -> { @@ -552,7 +552,7 @@ messaging.createPush( "[SOUND]", // sound (optional) "[COLOR]", // color (optional) "[TAG]", // tag (optional) - "[BADGE]", // badge (optional) + 1, // badge (optional) true, // draft (optional) "" // scheduledAt (optional) new CoroutineCallback<>((result, error) -> { @@ -588,7 +588,7 @@ let message = try await messaging.createPush( sound: "[SOUND]", // optional color: "[COLOR]", // optional tag: "[TAG]", // optional - badge: "[BADGE]", // optional + badge: 1, // optional content_available: false, // optional critical: false, // optional priority: "normal", // optional @@ -762,14 +762,14 @@ var messaging = new Messaging(client); Message result = await messaging.CreateEmail( messageId: "[MESSAGE_ID]", subject: "[SUBJECT]", - content: "[CONTENT]" - topics: new List {} // optional - users: new List {} // optional - targets: new List {} // optional - cc: new List {} // optional - bcc: new List {} // optional - draft: true // optional - html: false // optional + content: "[CONTENT]" + topics: new List {} // optional + users: new List {} // optional + targets: new List {} // optional + cc: new List {} // optional + bcc: new List {} // optional + draft: true // optional + html: false // optional scheduledAt: ""); // optional ``` ```dart @@ -1046,11 +1046,11 @@ var messaging = new Messaging(client); Message result = await messaging.CreateSMS( messageId: "[MESSAGE_ID]", - content: "[CONTENT]" - topics: new List {} // optional - users: new List {} // optional - targets: new List {} // optional - draft: true // optional + content: "[CONTENT]" + topics: new List {} // optional + users: new List {} // optional + targets: new List {} // optional + draft: true // optional scheduledAt: ""); // optional ``` ```dart From 4be15cc0e65376080f5c1ae4b2b959f2c8155a45 Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Tue, 21 Jan 2025 11:24:06 +0000 Subject: [PATCH 3/4] Update src/routes/docs/products/messaging/messages/+page.markdoc Co-authored-by: Jake Barnby --- src/routes/docs/products/messaging/messages/+page.markdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/docs/products/messaging/messages/+page.markdoc b/src/routes/docs/products/messaging/messages/+page.markdoc index ac240ae740..e19eef4427 100644 --- a/src/routes/docs/products/messaging/messages/+page.markdoc +++ b/src/routes/docs/products/messaging/messages/+page.markdoc @@ -369,7 +369,7 @@ result = messaging.create_push( sound = '[SOUND]', # optional color = '[COLOR]', # optional tag = '[TAG]', # optional - badge = 1, // optional + badge = 1, # optional content_available = False, # optional critical = False, # optional priority = 'normal', # optional From 240fe0f501864deea618f40223653e9eae7ece42 Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Tue, 21 Jan 2025 11:24:18 +0000 Subject: [PATCH 4/4] Update src/routes/docs/products/messaging/messages/+page.markdoc Co-authored-by: Jake Barnby --- src/routes/docs/products/messaging/messages/+page.markdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/docs/products/messaging/messages/+page.markdoc b/src/routes/docs/products/messaging/messages/+page.markdoc index e19eef4427..4e45542c1d 100644 --- a/src/routes/docs/products/messaging/messages/+page.markdoc +++ b/src/routes/docs/products/messaging/messages/+page.markdoc @@ -473,7 +473,7 @@ void main() async { // Init SDK sound: '[SOUND]', // optional color: '[COLOR]', // optional tag: '[TAG]', // optional - badge: 1, // optional + badge: 1, // optional content_available: false, // optional critical: false, // optional priority: 'normal', // optional