                     UIUserNotificationType.Alert.rawValue, categories: [category])
             
         } else {
-            
             // 这里才开始向用户提示推送
             APService.registerForRemoteNotificationTypes(
                 UIUserNotificationType.Badge.rawValue |

                AvatarPod.wakeAvatar(userAvatar, completion: { _ ,_ in })
            }

            // 每个对话的最近 10 条消息（image or thumbnail）

            guard let realm = try? Realm() else {

    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        
        delay(0.5) { [weak self] in
            self?.askForNotification()
        }

        // 预先生成小头像
        cacheInAdvance()
    }
    
    func askForNotification() {

        if #available(iOS 9.0, *) {
            
            let replyAction = UIMutableUserNotificationAction()
