         case Message = "message"
         case OfficialMessage = "official_message"
         case FriendRequest = "friend_request"
+        case MessageDeleted = "message_deleted"
     }
 
     private var remoteNotificationType: RemoteNotificationType? {

                switch remoteNotificationType {

                case .Message:
                    syncUnreadMessages() {
                        completionHandler(UIBackgroundFetchResult.NewData)
                    }

                case .OfficialMessage:
                    officialMessages { messagesCount in
                        completionHandler(UIBackgroundFetchResult.NewData)
                        println("new officialMessages count: \(messagesCount)")
                    }

                case .FriendRequest:
                    if let subType = userInfo["subtype"] as? String {
                        if subType == "accepted" {
                            syncFriendshipsAndDoFurtherAction {

                            completionHandler(UIBackgroundFetchResult.NoData)
                        }
                    } else {
                        completionHandler(UIBackgroundFetchResult.NoData)
                    }

                case .MessageDeleted:

                    guard let
                        messageInfo = userInfo["message"] as? JSONDictionary,
                        messageID = messageInfo["id"] as? String,
                        realm = try? Realm(),
                        message = messageWithMessageID(messageID, inRealm: realm),
                        conversation = message.conversation
                    else {
                        break
                    }

                    let messages = messagesOfConversation(conversation, inRealm: realm)

                    var sectionDateMessage: Message?
                    if let currentMessageIndex = messages.indexOf(message) {
                        let previousMessageIndex = currentMessageIndex - 1
                        if let previousMessage = messages[safe: previousMessageIndex] {
                            if previousMessage.mediaType == MessageMediaType.SectionDate.rawValue {
                                sectionDateMessage = previousMessage
                            }
                        }
                    }

                    let _ = try? realm.write {

                        if let sectionDateMessage = sectionDateMessage {
                            realm.delete(sectionDateMessage)
                        }

                        message.deleteAttachmentInRealm(realm)
                        realm.delete(message)
                    }

                    completionHandler(UIBackgroundFetchResult.NoData)
                }

                // 非前台才记录启动通知类型
