Skip to content

Commit 788ce89

Browse files
Merge pull request #25 from appwrite/feat-push-params
Add new push message parameters
2 parents f75ad97 + c624023 commit 788ce89

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+393
-200
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-swift.svg?color=green&style=flat-square)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-swift.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-1.6.0-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.6.1-blue.svg?style=flat-square)
66
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
77
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
88
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
@@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies:
3333

3434
```swift
3535
dependencies: [
36-
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "6.1.0"),
36+
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "6.2.0"),
3737
],
3838
```
3939

Diff for: Sources/Appwrite/Client.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ open class Client {
2121
"x-sdk-name": "Swift",
2222
"x-sdk-platform": "server",
2323
"x-sdk-language": "swift",
24-
"x-sdk-version": "6.1.0",
24+
"x-sdk-version": "6.2.0",
2525
"x-appwrite-response-format": "1.6.0"
2626
]
2727

@@ -530,23 +530,23 @@ open class Client {
530530
if param is String
531531
|| param is Int
532532
|| param is Float
533+
|| param is Double
533534
|| param is Bool
534535
|| param is [String]
535536
|| param is [Int]
536537
|| param is [Float]
538+
|| param is [Double]
537539
|| param is [Bool]
538540
|| param is [String: Any]
539541
|| param is [Int: Any]
540542
|| param is [Float: Any]
543+
|| param is [Double: Any]
541544
|| param is [Bool: Any] {
542545
encodedParams[key] = param
543-
} else {
544-
let value = try! (param as! Encodable).toJson()
545-
546-
let range = value.index(value.startIndex, offsetBy: 1)..<value.index(value.endIndex, offsetBy: -1)
547-
let substring = value[range]
548-
549-
encodedParams[key] = substring
546+
} else if let encodable = param as? Encodable {
547+
encodedParams[key] = try encodable.toJson()
548+
} else if let param = param {
549+
encodedParams[key] = String(describing: param)
550550
}
551551
}
552552

Diff for: Sources/Appwrite/Services/Account.swift

+12-14
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ open class Account: Service {
214214
}
215215

216216
///
217-
/// List Identities
217+
/// List identities
218218
///
219219
/// Get the list of identities for the currently logged in user.
220220
///
@@ -402,7 +402,7 @@ open class Account: Service {
402402
}
403403

404404
///
405-
/// Create Authenticator
405+
/// Create authenticator
406406
///
407407
/// Add an authenticator app to be used as an MFA factor. Verify the
408408
/// authenticator using the [verify
@@ -439,7 +439,7 @@ open class Account: Service {
439439
}
440440

441441
///
442-
/// Verify Authenticator
442+
/// Verify authenticator
443443
///
444444
/// Verify an authenticator app after adding it using the [add
445445
/// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
@@ -480,7 +480,7 @@ open class Account: Service {
480480
}
481481

482482
///
483-
/// Verify Authenticator
483+
/// Verify authenticator
484484
///
485485
/// Verify an authenticator app after adding it using the [add
486486
/// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
@@ -503,7 +503,7 @@ open class Account: Service {
503503
}
504504

505505
///
506-
/// Delete Authenticator
506+
/// Delete authenticator
507507
///
508508
/// Delete an authenticator for a user by ID.
509509
///
@@ -531,7 +531,7 @@ open class Account: Service {
531531
}
532532

533533
///
534-
/// Create MFA Challenge
534+
/// Create MFA challenge
535535
///
536536
/// Begin the process of MFA verification after sign-in. Finish the flow with
537537
/// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
@@ -568,7 +568,7 @@ open class Account: Service {
568568
}
569569

570570
///
571-
/// Create MFA Challenge (confirmation)
571+
/// Create MFA challenge (confirmation)
572572
///
573573
/// Complete the MFA challenge by providing the one-time password. Finish the
574574
/// process of MFA verification by providing the one-time password. To begin
@@ -604,7 +604,7 @@ open class Account: Service {
604604
}
605605

606606
///
607-
/// List Factors
607+
/// List factors
608608
///
609609
/// List the factors available on the account to be used as a MFA challange.
610610
///
@@ -635,7 +635,7 @@ open class Account: Service {
635635
}
636636

637637
///
638-
/// Get MFA Recovery Codes
638+
/// Get MFA recovery codes
639639
///
640640
/// Get recovery codes that can be used as backup for MFA flow. Before getting
641641
/// codes, they must be generated using
@@ -669,7 +669,7 @@ open class Account: Service {
669669
}
670670

671671
///
672-
/// Create MFA Recovery Codes
672+
/// Create MFA recovery codes
673673
///
674674
/// Generate recovery codes as backup for MFA flow. It's recommended to
675675
/// generate and show then immediately after user successfully adds their
@@ -704,7 +704,7 @@ open class Account: Service {
704704
}
705705

706706
///
707-
/// Regenerate MFA Recovery Codes
707+
/// Regenerate MFA recovery codes
708708
///
709709
/// Regenerate recovery codes that can be used as backup for MFA flow. Before
710710
/// regenerating codes, they must be first generated using
@@ -1596,9 +1596,7 @@ open class Account: Service {
15961596
/// [POST
15971597
/// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
15981598
/// endpoint to complete the login process. The link sent to the user's email
1599-
/// address is valid for 1 hour. If you are on a mobile device you can leave
1600-
/// the URL parameter empty, so that the login completion will be handled by
1601-
/// your Appwrite instance by default.
1599+
/// address is valid for 1 hour.
16021600
///
16031601
/// A user is limited to 10 active sessions at a time by default. [Learn more
16041602
/// about session

Diff for: Sources/Appwrite/Services/Locale.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ open class Locale: Service {
4545
}
4646

4747
///
48-
/// List Locale Codes
48+
/// List locale codes
4949
///
5050
/// List of all locale codes in [ISO
5151
/// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).

Diff for: Sources/Appwrite/Services/Messaging.swift

+26-8
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,19 @@ open class Messaging: Service {
201201
/// @param String sound
202202
/// @param String color
203203
/// @param String tag
204-
/// @param String badge
204+
/// @param Int badge
205205
/// @param Bool draft
206206
/// @param String scheduledAt
207+
/// @param Bool contentAvailable
208+
/// @param Bool critical
209+
/// @param AppwriteEnums.MessagePriority priority
207210
/// @throws Exception
208211
/// @return array
209212
///
210213
open func createPush(
211214
messageId: String,
212-
title: String,
213-
body: String,
215+
title: String? = nil,
216+
body: String? = nil,
214217
topics: [String]? = nil,
215218
users: [String]? = nil,
216219
targets: [String]? = nil,
@@ -221,9 +224,12 @@ open class Messaging: Service {
221224
sound: String? = nil,
222225
color: String? = nil,
223226
tag: String? = nil,
224-
badge: String? = nil,
227+
badge: Int? = nil,
225228
draft: Bool? = nil,
226-
scheduledAt: String? = nil
229+
scheduledAt: String? = nil,
230+
contentAvailable: Bool? = nil,
231+
critical: Bool? = nil,
232+
priority: AppwriteEnums.MessagePriority? = nil
227233
) async throws -> AppwriteModels.Message {
228234
let apiPath: String = "/messaging/messages/push"
229235

@@ -243,7 +249,10 @@ open class Messaging: Service {
243249
"tag": tag,
244250
"badge": badge,
245251
"draft": draft,
246-
"scheduledAt": scheduledAt
252+
"scheduledAt": scheduledAt,
253+
"contentAvailable": contentAvailable,
254+
"critical": critical,
255+
"priority": priority
247256
]
248257

249258
let apiHeaders: [String: String] = [
@@ -285,6 +294,9 @@ open class Messaging: Service {
285294
/// @param Int badge
286295
/// @param Bool draft
287296
/// @param String scheduledAt
297+
/// @param Bool contentAvailable
298+
/// @param Bool critical
299+
/// @param AppwriteEnums.MessagePriority priority
288300
/// @throws Exception
289301
/// @return array
290302
///
@@ -304,7 +316,10 @@ open class Messaging: Service {
304316
tag: String? = nil,
305317
badge: Int? = nil,
306318
draft: Bool? = nil,
307-
scheduledAt: String? = nil
319+
scheduledAt: String? = nil,
320+
contentAvailable: Bool? = nil,
321+
critical: Bool? = nil,
322+
priority: AppwriteEnums.MessagePriority? = nil
308323
) async throws -> AppwriteModels.Message {
309324
let apiPath: String = "/messaging/messages/push/{messageId}"
310325
.replacingOccurrences(of: "{messageId}", with: messageId)
@@ -324,7 +339,10 @@ open class Messaging: Service {
324339
"tag": tag,
325340
"badge": badge,
326341
"draft": draft,
327-
"scheduledAt": scheduledAt
342+
"scheduledAt": scheduledAt,
343+
"contentAvailable": contentAvailable,
344+
"critical": critical,
345+
"priority": priority
328346
]
329347

330348
let apiHeaders: [String: String] = [

Diff for: Sources/Appwrite/Services/Storage.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ open class Storage: Service {
426426
}
427427

428428
///
429-
/// Delete File
429+
/// Delete file
430430
///
431431
/// Delete a file by its unique ID. Only users with write permissions have
432432
/// access to delete this resource.

Diff for: Sources/Appwrite/Services/Teams.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ open class Teams: Service {
286286
/// List team memberships
287287
///
288288
/// Use this endpoint to list a team's members using the team's ID. All team
289-
/// members have read access to this endpoint.
289+
/// members have read access to this endpoint. Hide sensitive attributes from
290+
/// the response by toggling membership privacy in the Console.
290291
///
291292
/// @param String teamId
292293
/// @param [String] queries
@@ -401,7 +402,8 @@ open class Teams: Service {
401402
/// Get team membership
402403
///
403404
/// Get a team member by the membership unique id. All team members have read
404-
/// access for this resource.
405+
/// access for this resource. Hide sensitive attributes from the response by
406+
/// toggling membership privacy in the Console.
405407
///
406408
/// @param String teamId
407409
/// @param String membershipId

Diff for: Sources/Appwrite/Services/Users.swift

+11-11
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ open class Users: Service {
305305
}
306306

307307
///
308-
/// List Identities
308+
/// List identities
309309
///
310310
/// Get identities for all users.
311311
///
@@ -1208,7 +1208,7 @@ open class Users: Service {
12081208
}
12091209

12101210
///
1211-
/// Delete Authenticator
1211+
/// Delete authenticator
12121212
///
12131213
/// Delete an authenticator app.
12141214
///
@@ -1246,7 +1246,7 @@ open class Users: Service {
12461246
}
12471247

12481248
///
1249-
/// Delete Authenticator
1249+
/// Delete authenticator
12501250
///
12511251
/// Delete an authenticator app.
12521252
///
@@ -1267,7 +1267,7 @@ open class Users: Service {
12671267
}
12681268

12691269
///
1270-
/// List Factors
1270+
/// List factors
12711271
///
12721272
/// List the factors available on the account to be used as a MFA challange.
12731273
///
@@ -1301,7 +1301,7 @@ open class Users: Service {
13011301
}
13021302

13031303
///
1304-
/// Get MFA Recovery Codes
1304+
/// Get MFA recovery codes
13051305
///
13061306
/// Get recovery codes that can be used as backup for MFA flow by User ID.
13071307
/// Before getting codes, they must be generated using
@@ -1338,7 +1338,7 @@ open class Users: Service {
13381338
}
13391339

13401340
///
1341-
/// Regenerate MFA Recovery Codes
1341+
/// Regenerate MFA recovery codes
13421342
///
13431343
/// Regenerate recovery codes that can be used as backup for MFA flow by User
13441344
/// ID. Before regenerating codes, they must be first generated using
@@ -1375,7 +1375,7 @@ open class Users: Service {
13751375
}
13761376

13771377
///
1378-
/// Create MFA Recovery Codes
1378+
/// Create MFA recovery codes
13791379
///
13801380
/// Generate recovery codes used as backup for MFA flow for User ID. Recovery
13811381
/// codes can be used as a MFA verification type in
@@ -1903,7 +1903,7 @@ open class Users: Service {
19031903
}
19041904

19051905
///
1906-
/// List User Targets
1906+
/// List user targets
19071907
///
19081908
/// List the messaging targets that are associated with a user.
19091909
///
@@ -1941,7 +1941,7 @@ open class Users: Service {
19411941
}
19421942

19431943
///
1944-
/// Create User Target
1944+
/// Create user target
19451945
///
19461946
/// Create a messaging target.
19471947
///
@@ -1991,7 +1991,7 @@ open class Users: Service {
19911991
}
19921992

19931993
///
1994-
/// Get User Target
1994+
/// Get user target
19951995
///
19961996
/// Get a user's push notification target by ID.
19971997
///
@@ -2028,7 +2028,7 @@ open class Users: Service {
20282028
}
20292029

20302030
///
2031-
/// Update User target
2031+
/// Update user target
20322032
///
20332033
/// Update a messaging target.
20342034
///

0 commit comments

Comments
 (0)