Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

Rev 22 | Rev 24 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 22 Rev 23
Línea 139... Línea 139...
139
    processNotification(userInfo: userInfo, isForeground: true)
139
    processNotification(userInfo: userInfo, isForeground: true)
140
    completionHandler([[.banner, .badge, .sound]])
140
    completionHandler([[.banner, .badge, .sound]])
141
  }
141
  }
Línea 142... Línea 142...
142
    
142
    
143
    private func processNotification(userInfo : [AnyHashable : Any], isForeground : Bool) {
-
 
144
        
-
 
145
        let userNotificationDao = UserNotificationDao.sharedInstance
143
    private func processNotification(userInfo : [AnyHashable : Any], isForeground : Bool) {
146
        let now = Date()
144
        let now = Date()
147
        let dateFormatter = DateFormatter()
145
        let dateFormatter = DateFormatter()
-
 
146
        dateFormatter.dateFormat = Constants.FORMAT_DATE_YMD
-
 
147
        
-
 
148
        let timeFormatter = DateFormatter()
-
 
149
        timeFormatter.dateFormat = Constants.FORMAT_TIME_12
148
        dateFormatter.dateFormat = Constants.FORMAT_DATETIME_SERVICE
150
        
-
 
151
        let dateOn = dateFormatter.string(from: now)
149
        let dateOn = dateFormatter.string(from: now)
152
        let timeOn = dateFormatter.string(from: now)
-
 
153
        
-
 
154
        let userNotificationDao = UserNotificationDao.sharedInstance
-
 
155
        var userNotification : UserNotificationModel
-
 
156
        
-
 
157
        
-
 
158
        if Config.DEBUG {
-
 
159
            userNotification = UserNotificationModel(userUuid: appData.userUuid, title: "userInfo", body: "\(userInfo)", viewed: 0, url: "", dateOn: dateOn, timeOn: timeOn)
-
 
160
            
-
 
161
 
-
 
162
            userNotificationDao.insert(userNotification: userNotification)
-
 
163
        }
150
                
164
        
151
        let title = userInfo["title"]  as? String ?? ""
165
        let title = userInfo["title"]  as? String ?? ""
152
        let body = userInfo["body"]  as? String ?? ""
166
        let body = userInfo["body"]  as? String ?? ""
153
        let url = userInfo["url"] as? String ?? ""
167
        let url = userInfo["url"] as? String ?? ""
154
        let command = userInfo["command"] as? String ?? ""
168
        let command = userInfo["command"] as? String ?? ""
Línea 155... Línea -...
155
        let new_capsules = Int(userInfo["new_capsules"] as? String ?? "") ?? 0
-
 
156
 
169
        let new_capsules = Int(userInfo["new_capsules"] as? String ?? "") ?? 0
157
        var userNotification : UserNotificationModel
-
 
158
        
-
 
159
        userNotification = UserNotificationModel(userUuid: appData.userUuid, title: "userInfo", description: "\(userInfo)", viewed: 0, url: "", addedOn: dateOn)
170
 
160
        userNotificationDao.insert(userNotification: userNotification)
171
    
161
        if command == "signout" {
172
        if command == "signout" {
162
            NotificationCenter.default.post(name: Constants.NOTIFICATION_NAME_COMMAND_EXIT , object: self, userInfo: nil)
173
            NotificationCenter.default.post(name: Constants.NOTIFICATION_NAME_COMMAND_EXIT , object: self, userInfo: nil)
163
        }
174
        }
Línea 164... Línea 175...
164
        if command == "content-refresh" {
175
        if command == "content-refresh" && new_capsules > 0 {
165
            let userinfo = ["new_capsules" : String("new_capsules"), "is_foreground" : (isForeground ? "1" : "0")]
176
            let userinfo = ["new_capsules" : String(new_capsules), "is_foreground" : (isForeground ? "1" : "0")]
Línea 166... Línea 177...
166
            
177
            
167
            NotificationCenter.default.post(name: Constants.NOTIFICATION_NAME_COMMAND_REFRESH_CONTENT , object: self, userInfo: userinfo)
178
            NotificationCenter.default.post(name: Constants.NOTIFICATION_NAME_COMMAND_REFRESH_CONTENT , object: self, userInfo: userinfo)
168
        }
179
        }
Línea -... Línea 180...
-
 
180
        
169
        
181
        
Línea -... Línea 182...
-
 
182
        if !title.isEmpty && !body.isEmpty {
170
        
183
 
171
        if !title.isEmpty && !body.isEmpty {
184
            userNotification = UserNotificationModel(userUuid: appData.userUuid, title: title, body: body, viewed: 0, url: url, dateOn: dateOn, timeOn: timeOn)
Línea 172... Línea 185...
172
            
185