feat: Implement FCM token handling and dialog cache management; enhance user experience and performance

This commit is contained in:
k1ngsterr1
2026-01-17 05:53:27 +05:00
parent c9724b3bb7
commit 52ffc22763
9 changed files with 333 additions and 65 deletions

View File

@@ -454,8 +454,8 @@ class PacketChunk : Packet() {
}
/**
* Push Token packet (ID: 0x0A)
* Отправка FCM/APNS токена на сервер для push-уведомлений
* Push Token packet (ID: 0x0A) - DEPRECATED
* Старый формат, заменен на PacketPushNotification (0x10)
*/
class PacketPushToken : Packet() {
var privateKey: String = ""
@@ -482,3 +482,39 @@ class PacketPushToken : Packet() {
return stream
}
}
/**
* Push Notification Action
*/
enum class PushNotificationAction(val value: Int) {
SUBSCRIBE(0),
UNSUBSCRIBE(1)
}
/**
* Push Notification packet (ID: 0x10)
* Отправка FCM/APNS токена на сервер для push-уведомлений (новый формат)
* Совместим с React Native версией
*/
class PacketPushNotification : Packet() {
var notificationsToken: String = ""
var action: PushNotificationAction = PushNotificationAction.SUBSCRIBE
override fun getPacketId(): Int = 0x10
override fun receive(stream: Stream) {
notificationsToken = stream.readString()
action = when (stream.readInt8()) {
1 -> PushNotificationAction.UNSUBSCRIBE
else -> PushNotificationAction.SUBSCRIBE
}
}
override fun send(): Stream {
val stream = Stream()
stream.writeInt16(getPacketId())
stream.writeString(notificationsToken)
stream.writeInt8(action.value)
return stream
}
}