         contentHandler?(content)
     }
     
-    func notificationContent(forEvent event: MXEvent, inAccount account: MXKAccount, onComplete: @escaping (UNNotificationContent?) -> Void) {
+    func notificationContent(forEvent event: MXEvent, inSession session: MXSession, onComplete: @escaping (UNNotificationContent?) -> Void) {
         guard let content = event.content, content.count > 0 else {
             NSLog("[NotificationService][Push] notificationContentForEvent: empty event content")
             onComplete(nil)
             return
         }
         
-        guard let room = account.mxSession.room(withRoomId: event.roomId) else {
+        guard let room = MXRoom(roomId: event.roomId, matrixSession: session, andStore: store) else {
             NSLog("[NotificationService][Push] notificationBodyForEvent: Unknown room")
             onComplete(nil)
             return
         }
+        
         let pushRule = room.getRoomPushRule()
         
-        room.state({ (roomState: MXRoomState!) in
-            
+        //  initialize a temporary file store, just to load the room state
+        let fileStore = MXFileStore(credentials: session.credentials)
+        
+        MXRoomState.load(from: fileStore, withRoomId: event.roomId, matrixSession: session) { (roomState) in
+            guard let roomState = roomState else {
+                NSLog("[NotificationService] notificationContentForEvent: Could not load the room state")
+                onComplete(nil)
+                return
+            }
+
             var notificationTitle: String?
             var notificationBody: String?
             
             var threadIdentifier = room.roomId
             let eventSenderName = roomState.members.memberName(event.sender)
-            let currentUserId = account.mxCredentials.userId
+            let currentUserId = session.credentials.userId
             
             switch event.eventType {
             case .roomMessage, .roomEncrypted:

        
        let userInfo = content.userInfo
        NSLog("[NotificationService] Payload came: \(userInfo)")
        let roomId = userInfo["room_id"] as? String
        let eventId = userInfo["event_id"] as? String

        guard roomId != nil, eventId != nil else {
            //  it's not a Matrix notification, do not change the content
            NSLog("[NotificationService] didReceiveRequest: This is not a Matrix notification.")
            contentHandler(content)

    }
    
    func launchBackgroundSync() {
        guard let mxSession = mxSession else {
            NSLog("[NotificationService] launchBackgroundSync: mxSession is missing.")
            self.fallbackToOriginalContent()
            return
        }

        //  launch an initial background sync
        mxSession.initialBackgroundSync(withTimeout: 20000) { [weak self] (response) in
            switch response {
            case .success:
                guard let self = self else {
                    NSLog("[NotificationService] launchBackgroundSync: MXSession.initialBackgroundSync returned too late successfully")
                    return
                }
                self.fetchEvent()
                break
            case .failure(let error):
                guard let self = self else {
                    NSLog("[NotificationService] launchBackgroundSync: MXSession.initialBackgroundSync returned too late with error: \(String(describing: error))")
                    return
                }
                NSLog("[NotificationService] launchBackgroundSync: MXSession.initialBackgroundSync returned with error: \(String(describing: error))")
                self.fallbackToOriginalContent()
                break
            }
        }
    }
    
    func processEvent(_ event: MXEvent) {
        guard let content = originalContent, let mxSession = mxSession else {
            self.fallbackToOriginalContent()
            return
        }

        self.notificationContent(forEvent: event, inSession: mxSession) { (notificationContent) in
            //  close store
            self.store.close()
            
            // Modify the notification content here...
            if let newContent = notificationContent {
