feat(push-notification): 添加用户登录后自动更新推送token绑定功能
- 新增updateTokenUserId方法用于更新设备令牌的用户ID绑定关系 - 添加onUserLogin方法在用户登录成功后自动更新token绑定 - 优化checkAndRegisterToken逻辑,确保每次应用启动都更新用户ID绑定 - 修改UpdateTokenRequest接口,将appVersion和osVersion设为可选参数 - 在用户登录成功后自动触发推送token用户ID绑定更新
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { api, setAuthToken, STORAGE_KEYS } from '@/services/api';
|
||||
import { pushNotificationManager } from '@/services/pushNotificationManager';
|
||||
import { BodyMeasurementsDto, updateBodyMeasurements, updateUser, UpdateUserDto } from '@/services/users';
|
||||
import AsyncStorage from '@/utils/kvStore';
|
||||
import { createAsyncThunk, createSelector, createSlice, PayloadAction } from '@reduxjs/toolkit';
|
||||
@@ -335,6 +336,11 @@ const userSlice = createSlice({
|
||||
if (!state.profile?.name || !state.profile.name.trim()) {
|
||||
state.profile.name = DEFAULT_MEMBER_NAME;
|
||||
}
|
||||
|
||||
// 登录成功后,更新推送通知token的用户ID绑定
|
||||
pushNotificationManager.onUserLogin().catch((error: any) => {
|
||||
console.error('登录后更新推送通知token用户ID绑定失败:', error);
|
||||
});
|
||||
})
|
||||
.addCase(login.rejected, (state, action) => {
|
||||
state.loading = false;
|
||||
|
||||
Reference in New Issue
Block a user