Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

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

Rev 26 Rev 27
Línea 114... Línea 114...
114
            if data.userInfo != nil {
114
            if data.userInfo != nil {
115
                let newCapsules = Int(data.userInfo?["new_capsules"]! as? String ?? "0") ?? 0
115
                let newCapsules = Int(data.userInfo?["new_capsules"]! as? String ?? "0") ?? 0
116
                let isForeground = (Int(data.userInfo?["is_foreground"]! as? String ?? "0") ?? 0) == 1
116
                let isForeground = (Int(data.userInfo?["is_foreground"]! as? String ?? "0") ?? 0) == 1
Línea 117... Línea 117...
117
                
117
                
-
 
118
                if newCapsules > 0 {
-
 
119
                    let title = data.userInfo?["title"]! as? String ?? ""
118
                if newCapsules > 0 {
120
                    let body = data.userInfo?["body"]! as? String ?? ""
-
 
121
                    
-
 
122
                    let command = Constants.NOTIFICATION_COMMAND_REFRESH_CONTENT
-
 
123
                    let now = Date()
-
 
124
                    let dateFormatter = DateFormatter()
-
 
125
                    dateFormatter.dateFormat = Constants.FORMAT_DATE_YMD
-
 
126
                        
-
 
127
                    let timeFormatter = DateFormatter()
-
 
128
                    timeFormatter.dateFormat = Constants.FORMAT_TIME_12
-
 
129
                        
-
 
130
                    let dateOn = dateFormatter.string(from: now)
-
 
131
                    let timeOn = timeFormatter.string(from: now)
-
 
132
                        
-
 
133
                    let userNotificationDao = UserNotificationDao.sharedInstance
-
 
134
                    var userNotification : UserNotificationModel  = UserNotificationModel(userUuid: appData.userUuid, title: title, body: body, viewed: 0, url: "", command: command, dateOn: dateOn, timeOn: timeOn)
-
 
135
                        
-
 
136
                        
-
 
137
 
-
 
138
                    userNotificationDao.insert(userNotification: userNotification)
-
 
139
                    
-
 
140
                    
119
                
141
                    
Línea 120... Línea 142...
120
                    let message = newCapsules == 1 ? Config.LANG_MESSAGE_NEW_CONTENT_THERE_IS_ONE_CAPSULE : Config.LANG_MESSAGE_NEW_CONTENT_THERE_ARE_MULTIPLE_CAPSULES.replacingOccurrences(of: "%s", with: String(newCapsules))
142
                    let message = newCapsules == 1 ? Config.LANG_MESSAGE_NEW_CONTENT_THERE_IS_ONE_CAPSULE : Config.LANG_MESSAGE_NEW_CONTENT_THERE_ARE_MULTIPLE_CAPSULES.replacingOccurrences(of: "%s", with: String(newCapsules))
121
                    
143
                    
122
                    if isForeground {
144
                    if isForeground {
Línea 147... Línea 169...
147
        { data in
169
        { data in
Línea 148... Línea 170...
148
            
170
            
149
            let title = data.userInfo?["title"]! as? String ?? ""
171
            let title = data.userInfo?["title"]! as? String ?? ""
150
            let body = data.userInfo?["body"]! as? String ?? ""
172
            let body = data.userInfo?["body"]! as? String ?? ""
151
            let url = data.userInfo?["url"]! as? String ?? ""
-
 
152
            let sNewCapsules = data.userInfo?["new_capsules"]! as? String ?? " 
-
 
Línea 153... Línea -...
153
            let newCapsules =  Int("sNewCapsules") ?? 0
-
 
-
 
173
            let url = data.userInfo?["url"]! as? String ?? ""
154
 
174
 
-
 
175
            let command = url.isEmpty ? "" : Constants.NOTIFICATION_COMMAND_OPEN_URL
-
 
176
            let viewed = url.isEmpty ? 1 : 0
-
 
177
            let now = Date()
Línea 155... Línea -...
155
        
-
 
156
            if !title.isEmpty && !body.isEmpty {
-
 
157
                
-
 
158
                var command : String
-
 
159
                if !url.isEmpty {
-
 
160
                    command = Constants.NOTIFICATION_COMMAND_OPEN_URL
-
 
161
                } else if newCapsules > 0 {
-
 
162
                    command = Constants.NOTIFICATION_COMMAND_REFRESH_CONTENT
-
 
163
                } else {
-
 
164
                    command = ""
-
 
165
                }
-
 
166
                
-
 
167
                
-
 
168
                let now = Date()
-
 
169
                let dateFormatter = DateFormatter()
178
            let dateFormatter = DateFormatter()
170
                dateFormatter.dateFormat = Constants.FORMAT_DATE_YMD
179
            dateFormatter.dateFormat = Constants.FORMAT_DATE_YMD
Línea 171... Línea 180...
171
                
180
                
172
                let timeFormatter = DateFormatter()
181
            let timeFormatter = DateFormatter()
Línea 173... Línea 182...
173
                timeFormatter.dateFormat = Constants.FORMAT_TIME_12
182
            timeFormatter.dateFormat = Constants.FORMAT_TIME_12
174
                
183
                
Línea 175... Línea 184...
175
                let dateOn = dateFormatter.string(from: now)
184
            let dateOn = dateFormatter.string(from: now)
176
                let timeOn = timeFormatter.string(from: now)
-
 
177
                
-
 
178
                let userNotificationDao = UserNotificationDao.sharedInstance
-
 
179
                var userNotification : UserNotificationModel  = UserNotificationModel(userUuid: appData.userUuid, title: title, body: body, viewed: command.isEmpty ? 1 : 0, url: url, command: command, dateOn: dateOn, timeOn: timeOn)
185
            let timeOn = timeFormatter.string(from: now)
Línea 180... Línea 186...
180
                
186
                
181
                
187
            let userNotificationDao = UserNotificationDao.sharedInstance