feat: Implement FCM token handling and dialog cache management; enhance user experience and performance
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user