登出时取消消息推送注册
This commit is contained in:
@@ -49,7 +49,7 @@ object AppState {
|
|||||||
UserId = resp.id
|
UserId = resp.id
|
||||||
|
|
||||||
// 注册 JPush
|
// 注册 JPush
|
||||||
Messaging.RegistDevice(scope, context)
|
Messaging.registerDevice(scope, context)
|
||||||
// 注册 Trtc
|
// 注册 Trtc
|
||||||
val config = V2TIMSDKConfig()
|
val config = V2TIMSDKConfig()
|
||||||
|
|
||||||
@@ -140,6 +140,5 @@ object AppState {
|
|||||||
TrtcService::class.java
|
TrtcService::class.java
|
||||||
)
|
)
|
||||||
context.stopService(trtcService)
|
context.stopService(trtcService)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,9 @@ import android.content.Context
|
|||||||
object ConstVars {
|
object ConstVars {
|
||||||
// api 地址
|
// api 地址
|
||||||
// const val BASE_SERVER = "http://192.168.31.130:8088"
|
// const val BASE_SERVER = "http://192.168.31.130:8088"
|
||||||
|
const val BASE_SERVER = "http://192.168.142.140:8088"
|
||||||
// const val BASE_SERVER = "https://8.137.22.101:8088"
|
// const val BASE_SERVER = "https://8.137.22.101:8088"
|
||||||
const val BASE_SERVER = "https://rider-pro.aiosman.com/beta_api"
|
// const val BASE_SERVER = "https://rider-pro.aiosman.com/beta_api"
|
||||||
|
|
||||||
const val MOMENT_LIKE_CHANNEL_ID = "moment_like"
|
const val MOMENT_LIKE_CHANNEL_ID = "moment_like"
|
||||||
const val MOMENT_LIKE_CHANNEL_NAME = "Moment Like"
|
const val MOMENT_LIKE_CHANNEL_NAME = "Moment Like"
|
||||||
|
|||||||
@@ -11,12 +11,17 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
object Messaging {
|
object Messaging {
|
||||||
fun RegistDevice(scope: CoroutineScope, context: Context) {
|
fun registerDevice(scope: CoroutineScope, context: Context) {
|
||||||
|
|
||||||
registerJpush(scope, context)
|
registerJpush(scope, context)
|
||||||
// registerFCM(scope)
|
// registerFCM(scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun unregisterDevice(context: Context) {
|
||||||
|
unregisterJpush(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun registerJpush(scope: CoroutineScope, context: Context) {
|
fun registerJpush(scope: CoroutineScope, context: Context) {
|
||||||
val accountService: AccountService = AccountServiceImpl()
|
val accountService: AccountService = AccountServiceImpl()
|
||||||
val regId = JPushInterface.getRegistrationID(context)
|
val regId = JPushInterface.getRegistrationID(context)
|
||||||
@@ -25,6 +30,12 @@ object Messaging {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun unregisterJpush(context: Context) {
|
||||||
|
val accountService: AccountService = AccountServiceImpl()
|
||||||
|
val regId = JPushInterface.getRegistrationID(context)
|
||||||
|
accountService.unregisterMessageChannel(client = "jpush", identifier = regId)
|
||||||
|
}
|
||||||
|
|
||||||
fun registerFCM(scope: CoroutineScope) {
|
fun registerFCM(scope: CoroutineScope) {
|
||||||
val accountService: AccountService = AccountServiceImpl()
|
val accountService: AccountService = AccountServiceImpl()
|
||||||
FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task ->
|
FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task ->
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.aiosman.riderpro.data.api.RegisterMessageChannelRequestBody
|
|||||||
import com.aiosman.riderpro.data.api.RegisterRequestBody
|
import com.aiosman.riderpro.data.api.RegisterRequestBody
|
||||||
import com.aiosman.riderpro.data.api.ResetPasswordRequestBody
|
import com.aiosman.riderpro.data.api.ResetPasswordRequestBody
|
||||||
import com.aiosman.riderpro.data.api.TrtcSignResponseBody
|
import com.aiosman.riderpro.data.api.TrtcSignResponseBody
|
||||||
|
import com.aiosman.riderpro.data.api.UnRegisterMessageChannelRequestBody
|
||||||
import com.aiosman.riderpro.data.api.UpdateNoticeRequestBody
|
import com.aiosman.riderpro.data.api.UpdateNoticeRequestBody
|
||||||
import com.aiosman.riderpro.data.api.UpdateUserLangRequestBody
|
import com.aiosman.riderpro.data.api.UpdateUserLangRequestBody
|
||||||
import com.aiosman.riderpro.entity.AccountFavouriteEntity
|
import com.aiosman.riderpro.entity.AccountFavouriteEntity
|
||||||
@@ -360,6 +361,11 @@ interface AccountService {
|
|||||||
*/
|
*/
|
||||||
suspend fun registerMessageChannel(client: String, identifier: String)
|
suspend fun registerMessageChannel(client: String, identifier: String)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消注册消息通道
|
||||||
|
*/
|
||||||
|
suspend fun unregisterMessageChannel(client: String, identifier: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置密码
|
* 重置密码
|
||||||
*/
|
*/
|
||||||
@@ -501,6 +507,10 @@ class AccountServiceImpl : AccountService {
|
|||||||
ApiClient.api.registerMessageChannel(RegisterMessageChannelRequestBody(client, identifier))
|
ApiClient.api.registerMessageChannel(RegisterMessageChannelRequestBody(client, identifier))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun unregisterMessageChannel(client: String, identifier: String) {
|
||||||
|
ApiClient.api.unRegisterMessageChannel(UnRegisterMessageChannelRequestBody(client, identifier))
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun resetPassword(email: String) {
|
override suspend fun resetPassword(email: String) {
|
||||||
val resp = ApiClient.api.resetPassword(
|
val resp = ApiClient.api.resetPassword(
|
||||||
ResetPasswordRequestBody(
|
ResetPasswordRequestBody(
|
||||||
|
|||||||
@@ -28,9 +28,8 @@ data class RegisterRequestBody(
|
|||||||
@SerializedName("username")
|
@SerializedName("username")
|
||||||
val username: String,
|
val username: String,
|
||||||
@SerializedName("password")
|
@SerializedName("password")
|
||||||
val password: String,
|
val password: String
|
||||||
|
)
|
||||||
)
|
|
||||||
|
|
||||||
data class LoginUserRequestBody(
|
data class LoginUserRequestBody(
|
||||||
@SerializedName("username")
|
@SerializedName("username")
|
||||||
@@ -96,6 +95,12 @@ data class RegisterMessageChannelRequestBody(
|
|||||||
val identifier: String,
|
val identifier: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class UnRegisterMessageChannelRequestBody(
|
||||||
|
@SerializedName("client")
|
||||||
|
val client: String,
|
||||||
|
@SerializedName("identifier")
|
||||||
|
val identifier: String,
|
||||||
|
)
|
||||||
data class ResetPasswordRequestBody(
|
data class ResetPasswordRequestBody(
|
||||||
@SerializedName("username")
|
@SerializedName("username")
|
||||||
val username: String,
|
val username: String,
|
||||||
@@ -151,10 +156,12 @@ data class CheckLoginCaptchaRequestBody(
|
|||||||
@SerializedName("username")
|
@SerializedName("username")
|
||||||
val username: String,
|
val username: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class GenerateLoginCaptchaRequestBody(
|
data class GenerateLoginCaptchaRequestBody(
|
||||||
@SerializedName("username")
|
@SerializedName("username")
|
||||||
val username: String,
|
val username: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class DotPosition(
|
data class DotPosition(
|
||||||
@SerializedName("index")
|
@SerializedName("index")
|
||||||
val index: Int,
|
val index: Int,
|
||||||
@@ -163,6 +170,7 @@ data class DotPosition(
|
|||||||
@SerializedName("y")
|
@SerializedName("y")
|
||||||
val y: Int,
|
val y: Int,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class CaptchaInfo(
|
data class CaptchaInfo(
|
||||||
@SerializedName("id")
|
@SerializedName("id")
|
||||||
val id: Int,
|
val id: Int,
|
||||||
@@ -318,6 +326,10 @@ interface RiderProAPI {
|
|||||||
@Body body: RegisterMessageChannelRequestBody
|
@Body body: RegisterMessageChannelRequestBody
|
||||||
): Response<Unit>
|
): Response<Unit>
|
||||||
|
|
||||||
|
@POST("account/my/messaging/unregister")
|
||||||
|
suspend fun unRegisterMessageChannel(
|
||||||
|
@Body body: UnRegisterMessageChannelRequestBody
|
||||||
|
): Response<Unit>
|
||||||
|
|
||||||
@GET("profile/{id}")
|
@GET("profile/{id}")
|
||||||
suspend fun getAccountProfileById(
|
suspend fun getAccountProfileById(
|
||||||
|
|||||||
@@ -12,8 +12,12 @@ import androidx.paging.Pager
|
|||||||
import androidx.paging.PagingConfig
|
import androidx.paging.PagingConfig
|
||||||
import androidx.paging.PagingData
|
import androidx.paging.PagingData
|
||||||
import androidx.paging.cachedIn
|
import androidx.paging.cachedIn
|
||||||
|
import cn.jpush.android.api.JPushInterface
|
||||||
import com.aiosman.riderpro.AppState
|
import com.aiosman.riderpro.AppState
|
||||||
import com.aiosman.riderpro.AppStore
|
import com.aiosman.riderpro.AppStore
|
||||||
|
import com.aiosman.riderpro.JpushService
|
||||||
|
import com.aiosman.riderpro.Messaging
|
||||||
|
import com.aiosman.riderpro.data.AccountProfile
|
||||||
import com.aiosman.riderpro.data.AccountService
|
import com.aiosman.riderpro.data.AccountService
|
||||||
import com.aiosman.riderpro.data.AccountServiceImpl
|
import com.aiosman.riderpro.data.AccountServiceImpl
|
||||||
import com.aiosman.riderpro.data.MomentService
|
import com.aiosman.riderpro.data.MomentService
|
||||||
@@ -73,15 +77,20 @@ object MyProfileViewModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun logout(context: Context) {
|
fun logout(context: Context) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
Messaging.unregisterDevice(context)
|
||||||
AppStore.apply {
|
AppStore.apply {
|
||||||
token = null
|
token = null
|
||||||
rememberMe = false
|
rememberMe = false
|
||||||
saveData()
|
saveData()
|
||||||
}
|
}
|
||||||
|
// 删除推送渠道
|
||||||
AppState.ReloadAppState(context)
|
AppState.ReloadAppState(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fun updateUserProfileBanner(bannerImageUrl: Uri?,file:File, context: Context) {
|
fun updateUserProfileBanner(bannerImageUrl: Uri?,file:File, context: Context) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val newBanner = bannerImageUrl?.let {
|
val newBanner = bannerImageUrl?.let {
|
||||||
|
|||||||
@@ -19,10 +19,7 @@ fun ProfileWrap(
|
|||||||
MyProfileViewModel.updateUserProfileBanner(uri, file, context)
|
MyProfileViewModel.updateUserProfileBanner(uri, file, context)
|
||||||
},
|
},
|
||||||
onLogout = {
|
onLogout = {
|
||||||
MyProfileViewModel.viewModelScope.launch {
|
|
||||||
MyProfileViewModel.logout(context)
|
MyProfileViewModel.logout(context)
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
profile = MyProfileViewModel.profile,
|
profile = MyProfileViewModel.profile,
|
||||||
sharedFlow = MyProfileViewModel.sharedFlow
|
sharedFlow = MyProfileViewModel.sharedFlow
|
||||||
|
|||||||
Reference in New Issue
Block a user