feat(notification): integrate expo-notifications for permission handling and deep linking
- Add expo-notifications dependency and configure with JPush plugin - Request notification permission on app launch for iOS/Android - Handle notification taps to navigate to chat or notifications screen - Add UI to check and request system notification permission in settings - Refactor background sync: WebSocket disconnects in background, JPush handles push - Add checkNotificationPermission() and requestNotificationPermission() to jpushService
This commit is contained in:
@@ -1101,7 +1101,14 @@ class WebSocketService {
|
||||
if (this.appStateSubscription) return;
|
||||
this.lastAppState = AppState.currentState;
|
||||
this.appStateSubscription = AppState.addEventListener('change', (nextState: AppStateStatus) => {
|
||||
// 进入后台时断开 WebSocket,由 JPush 负责后台推送通知
|
||||
if (this.lastAppState === 'active' && nextState.match(/inactive|background/)) {
|
||||
console.log('[WebSocket] App entering background, disconnecting');
|
||||
this.disconnect();
|
||||
}
|
||||
// 回到前台时重连 WebSocket
|
||||
if (this.lastAppState.match(/inactive|background/) && nextState === 'active' && !this.isConnected()) {
|
||||
console.log('[WebSocket] App returning to foreground, reconnecting');
|
||||
this.reconnectAttempts = 0;
|
||||
this.connect();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user