Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 24.0.0

* Breaking: Added `unsubscribe()`, `update()`, and `close()` for Realtime subscription lifecycle.
* Added: Added `userPhone` to the `Membership` model.
* Updated: Updated `X-Appwrite-Response-Format` header to `1.9.2`.

## 23.1.0

* Added `x` OAuth provider to `OAuthProvider` enum
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-android.svg?color=green&style=flat-square)
![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.9.1-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.9.2-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
Expand Down Expand Up @@ -38,7 +38,7 @@ repositories {
Next, add the dependency to your project's `build.gradle(.kts)` file:

```groovy
implementation("io.appwrite:sdk-for-android:23.1.0")
implementation("io.appwrite:sdk-for-android:24.0.0")
```

### Maven
Expand All @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file:
<dependency>
<groupId>io.appwrite</groupId>
<artifactId>sdk-for-android</artifactId>
<version>23.1.0</version>
<version>24.0.0</version>
</dependency>
</dependencies>
```
Expand Down
4 changes: 2 additions & 2 deletions library/src/main/java/io/appwrite/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class Client @JvmOverloads constructor(
"x-sdk-name" to "Android",
"x-sdk-platform" to "client",
"x-sdk-language" to "android",
"x-sdk-version" to "23.1.0",
"x-appwrite-response-format" to "1.9.1"
"x-sdk-version" to "24.0.0",
"x-appwrite-response-format" to "1.9.2"
)
config = mutableMapOf()

Expand Down
8 changes: 8 additions & 0 deletions library/src/main/java/io/appwrite/models/Membership.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ data class Membership(
@SerializedName("userEmail")
val userEmail: String,

/**
* User phone number. Hide this attribute by toggling membership privacy in the Console.
*/
@SerializedName("userPhone")
val userPhone: String,
Comment on lines +49 to +50

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 userPhone declared non-nullable, will crash when privacy is enabled

userPhone is typed as String (non-nullable). The API docs note "Hide this attribute by toggling membership privacy in the Console," meaning the field can be absent or null in the response. When Membership.from(map) executes map["userPhone"] as String against a response that omits this key, map["userPhone"] returns null, and the unchecked cast throws a ClassCastException, crashing the caller.

Declare the field as String? (nullable) and update from() accordingly:

Suggested change
@SerializedName("userPhone")
val userPhone: String,
@SerializedName("userPhone")
val userPhone: String?


/**
* Team ID.
*/
Expand Down Expand Up @@ -93,6 +99,7 @@ data class Membership(
"userId" to userId as Any,
"userName" to userName as Any,
"userEmail" to userEmail as Any,
"userPhone" to userPhone as Any,
"teamId" to teamId as Any,
"teamName" to teamName as Any,
"invited" to invited as Any,
Expand All @@ -114,6 +121,7 @@ data class Membership(
userId = map["userId"] as String,
userName = map["userName"] as String,
userEmail = map["userEmail"] as String,
userPhone = map["userPhone"] as String,
teamId = map["teamId"] as String,
teamName = map["teamName"] as String,
invited = map["invited"] as String,
Expand Down
20 changes: 20 additions & 0 deletions library/src/main/java/io/appwrite/models/RealtimeModels.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,29 @@ package io.appwrite.models
import kotlin.collections.Collection
import java.io.Closeable

data class RealtimeSubscriptionUpdate(
val channels: Collection<Any>? = null,
val queries: Collection<String>? = null
)

data class RealtimeSubscription(
/**
* Remove this subscription only. The WebSocket stays open so other subscriptions keep
* receiving events — use [Realtime.disconnect] for full teardown.
*/
val unsubscribe: () -> Unit,

/**
* Replace the channels and/or queries on this subscription without recreating it.
*/
val update: (RealtimeSubscriptionUpdate) -> Unit,

private val close: () -> Unit
) : Closeable {
/**
* Alias of [unsubscribe] that also tears the socket down when this was the last active
* subscription. Prefer [unsubscribe] plus [Realtime.disconnect] for explicit control.
*/
override fun close() = close.invoke()
}

Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/services/Account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2242,4 +2242,4 @@ class Account(client: Client) : Service(client) {
}


}
}
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/services/Avatars.kt
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,4 @@ class Avatars(client: Client) : Service(client) {
}


}
}
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/services/Databases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -859,4 +859,4 @@ class Databases(client: Client) : Service(client) {
nestedType = classOf(),
)

}
}
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/services/Functions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ class Functions(client: Client) : Service(client) {
}


}
}
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/services/Graphql.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ class Graphql(client: Client) : Service(client) {
}


}
}
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/services/Locale.kt
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,4 @@ class Locale(client: Client) : Service(client) {
}


}
}
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/services/Messaging.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ class Messaging(client: Client) : Service(client) {
}


}
}
Loading