Skip to content

Commit fdf87cd

Browse files
Merge pull request #35 from appwrite/feat-push-params
Add new push message parameters
2 parents 33bfc16 + 323ef57 commit fdf87cd

File tree

11 files changed

+43
-25
lines changed

11 files changed

+43
-25
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors.
1+
Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Appwrite Ruby SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-1.6.0-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-1.6.1-blue.svg?style=flat-square)
55
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

appwrite.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |spec|
22

33
spec.name = 'appwrite'
4-
spec.version = '13.0.1'
4+
spec.version = '13.1.0'
55
spec.license = 'BSD-3-Clause'
66
spec.summary = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API'
77
spec.author = 'Appwrite Team'

docs/examples/messaging/create-push.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ messaging = Messaging.new(client)
1111

1212
result = messaging.create_push(
1313
message_id: '<MESSAGE_ID>',
14-
title: '<TITLE>',
15-
body: '<BODY>',
14+
title: '<TITLE>', # optional
15+
body: '<BODY>', # optional
1616
topics: [], # optional
1717
users: [], # optional
1818
targets: [], # optional
@@ -23,7 +23,10 @@ result = messaging.create_push(
2323
sound: '<SOUND>', # optional
2424
color: '<COLOR>', # optional
2525
tag: '<TAG>', # optional
26-
badge: '<BADGE>', # optional
26+
badge: null, # optional
2727
draft: false, # optional
28-
scheduled_at: '' # optional
28+
scheduled_at: '', # optional
29+
content_available: false, # optional
30+
critical: false, # optional
31+
priority: MessagePriority::NORMAL # optional
2932
)

docs/examples/messaging/update-push.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ result = messaging.update_push(
2525
tag: '<TAG>', # optional
2626
badge: null, # optional
2727
draft: false, # optional
28-
scheduled_at: '' # optional
28+
scheduled_at: '', # optional
29+
content_available: false, # optional
30+
critical: false, # optional
31+
priority: MessagePriority::NORMAL # optional
2932
)

lib/appwrite.rb

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
require_relative 'appwrite/enums/runtime'
117117
require_relative 'appwrite/enums/execution_method'
118118
require_relative 'appwrite/enums/name'
119+
require_relative 'appwrite/enums/message_priority'
119120
require_relative 'appwrite/enums/smtp_encryption'
120121
require_relative 'appwrite/enums/compression'
121122
require_relative 'appwrite/enums/image_gravity'

lib/appwrite/client.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize
1515
'x-sdk-name'=> 'Ruby',
1616
'x-sdk-platform'=> 'server',
1717
'x-sdk-language'=> 'ruby',
18-
'x-sdk-version'=> '13.0.1',
18+
'x-sdk-version'=> '13.1.0',
1919
'X-Appwrite-Response-Format' => '1.6.0'
2020
}
2121
@endpoint = 'https://cloud.appwrite.io/v1'
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module Appwrite
2+
module Enums
3+
module MessagePriority
4+
NORMAL = 'normal'
5+
HIGH = 'high'
6+
end
7+
end
8+
end

lib/appwrite/enums/runtime.rb

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ module Runtime
5959
BUN_1_1 = 'bun-1.1'
6060
GO_1_23 = 'go-1.23'
6161
STATIC_1 = 'static-1'
62+
FLUTTER_3_24 = 'flutter-3.24'
6263
end
6364
end
6465
end

lib/appwrite/services/account.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -1206,9 +1206,7 @@ def create_email_token(user_id:, email:, phrase: nil)
12061206
# [POST
12071207
# /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
12081208
# endpoint to complete the login process. The link sent to the user's email
1209-
# address is valid for 1 hour. If you are on a mobile device you can leave
1210-
# the URL parameter empty, so that the login completion will be handled by
1211-
# your Appwrite instance by default.
1209+
# address is valid for 1 hour.
12121210
#
12131211
# A user is limited to 10 active sessions at a time by default. [Learn more
12141212
# about session

lib/appwrite/services/messaging.rb

+17-13
Original file line numberDiff line numberDiff line change
@@ -156,33 +156,28 @@ def update_email(message_id:, topics: nil, users: nil, targets: nil, subject: ni
156156
# @param [Array] topics List of Topic IDs.
157157
# @param [Array] users List of User IDs.
158158
# @param [Array] targets List of Targets IDs.
159-
# @param [Hash] data Additional Data for push notification.
159+
# @param [Hash] data Additional key-value pair data for push notification.
160160
# @param [String] action Action for push notification.
161161
# @param [String] image Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.
162162
# @param [String] icon Icon for push notification. Available only for Android and Web Platform.
163-
# @param [String] sound Sound for push notification. Available only for Android and IOS Platform.
163+
# @param [String] sound Sound for push notification. Available only for Android and iOS Platform.
164164
# @param [String] color Color for push notification. Available only for Android Platform.
165165
# @param [String] tag Tag for push notification. Available only for Android Platform.
166-
# @param [String] badge Badge for push notification. Available only for IOS Platform.
166+
# @param [Integer] badge Badge for push notification. Available only for iOS Platform.
167167
# @param [] draft Is message a draft
168168
# @param [String] scheduled_at Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.
169+
# @param [] content_available If set to true, the notification will be delivered in the background. Available only for iOS Platform.
170+
# @param [] critical If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.
171+
# @param [MessagePriority] priority Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification.
169172
#
170173
# @return [Message]
171-
def create_push(message_id:, title:, body:, topics: nil, users: nil, targets: nil, data: nil, action: nil, image: nil, icon: nil, sound: nil, color: nil, tag: nil, badge: nil, draft: nil, scheduled_at: nil)
174+
def create_push(message_id:, title: nil, body: nil, topics: nil, users: nil, targets: nil, data: nil, action: nil, image: nil, icon: nil, sound: nil, color: nil, tag: nil, badge: nil, draft: nil, scheduled_at: nil, content_available: nil, critical: nil, priority: nil)
172175
api_path = '/messaging/messages/push'
173176

174177
if message_id.nil?
175178
raise Appwrite::Exception.new('Missing required parameter: "messageId"')
176179
end
177180

178-
if title.nil?
179-
raise Appwrite::Exception.new('Missing required parameter: "title"')
180-
end
181-
182-
if body.nil?
183-
raise Appwrite::Exception.new('Missing required parameter: "body"')
184-
end
185-
186181
api_params = {
187182
messageId: message_id,
188183
title: title,
@@ -200,6 +195,9 @@ def create_push(message_id:, title:, body:, topics: nil, users: nil, targets: ni
200195
badge: badge,
201196
draft: draft,
202197
scheduledAt: scheduled_at,
198+
contentAvailable: content_available,
199+
critical: critical,
200+
priority: priority,
203201
}
204202

205203
api_headers = {
@@ -235,9 +233,12 @@ def create_push(message_id:, title:, body:, topics: nil, users: nil, targets: ni
235233
# @param [Integer] badge Badge for push notification. Available only for iOS platforms.
236234
# @param [] draft Is message a draft
237235
# @param [String] scheduled_at Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.
236+
# @param [] content_available If set to true, the notification will be delivered in the background. Available only for iOS Platform.
237+
# @param [] critical If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.
238+
# @param [MessagePriority] priority Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification.
238239
#
239240
# @return [Message]
240-
def update_push(message_id:, topics: nil, users: nil, targets: nil, title: nil, body: nil, data: nil, action: nil, image: nil, icon: nil, sound: nil, color: nil, tag: nil, badge: nil, draft: nil, scheduled_at: nil)
241+
def update_push(message_id:, topics: nil, users: nil, targets: nil, title: nil, body: nil, data: nil, action: nil, image: nil, icon: nil, sound: nil, color: nil, tag: nil, badge: nil, draft: nil, scheduled_at: nil, content_available: nil, critical: nil, priority: nil)
241242
api_path = '/messaging/messages/push/{messageId}'
242243
.gsub('{messageId}', message_id)
243244

@@ -261,6 +262,9 @@ def update_push(message_id:, topics: nil, users: nil, targets: nil, title: nil,
261262
badge: badge,
262263
draft: draft,
263264
scheduledAt: scheduled_at,
265+
contentAvailable: content_available,
266+
critical: critical,
267+
priority: priority,
264268
}
265269

266270
api_headers = {

0 commit comments

Comments
 (0)