Proyectos de Subversion Iphone Microlearning - Inconcert

Rev

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

Rev 2 Rev 17
Línea 16... Línea 16...
16
    @StateObject private var networkMonitor = NetworkMonitor()
16
    @StateObject private var networkMonitor = NetworkMonitor()
17
    @State private var showToast : Bool = true
17
    @State private var showToast : Bool = true
Línea 18... Línea 18...
18
    
18
    
19
    private var appData = AppData.sharedInstance
19
    private var appData = AppData.sharedInstance
-
 
20
    private var localNotification = LocalNotificationManager()
-
 
21
    
Línea 20... Línea 22...
20
    private var localNotification = LocalNotificationManager()
22
 
21
 
23
 
22
    var body: some View {
24
    var body: some View {
Línea 146... Línea 148...
146
                timeFormatter.dateFormat = Constants.FORMAT_TIME_12
148
                timeFormatter.dateFormat = Constants.FORMAT_TIME_12
Línea 147... Línea 149...
147
                        
149
                        
148
                let dateOn = dateFormatter.string(from: now)
150
                let dateOn = dateFormatter.string(from: now)
Línea 149... Línea 151...
149
                let timeOn = timeFormatter.string(from: now)
151
                let timeOn = timeFormatter.string(from: now)
150
                        
152
                        
Línea 151... Línea 153...
151
                let userNotificationDao = UserNotificationDao.sharedInstance
153
                let userNotificationDao = UserNotificationDao()
Línea 176... Línea 178...
176
                    appData.save()
178
                    appData.save()
177
                }
179
                }
178
            }
180
            }
Línea 179... Línea 181...
179
 
181
 
-
 
182
        }
-
 
183
        /*.onReceive(NotificationCenter.default.publisher(for: Constants.NOTIFICATION_NAME_DEVICE_REGISTER_NAME))
-
 
184
        { data in
-
 
185
            if data.userInfo != nil {
-
 
186
                let userInfo = data.userInfo!
-
 
187
                let new_uuid = userInfo["uuid"] as? String ?? ""
-
 
188
                
-
 
189
                
-
 
190
                if !new_uuid.isEmpty {
-
 
191
                    if appData.deviceUuid != new_uuid {
-
 
192
                        
-
 
193
                        var sync = SyncModel()
-
 
194
                        sync.data = new_uuid
-
 
195
                        sync.type = Constants.SYNC_ADAPTER_TYPE_DEVICE
-
 
196
                        
-
 
197
                        let syncDao = SyncDao()
-
 
198
                        if syncDao.insert(record: sync) > 0 {
-
 
199
                            appData.deviceUuid = new_uuid
-
 
200
                            appData.save()
-
 
201
                            
-
 
202
                            let syncAdapter = SyncAdapter()
-
 
203
                            syncAdapter.sync(isForeground: true) {
-
 
204
                                success in
-
 
205
                            }
-
 
206
                        }
-
 
207
                    }
-
 
208
                }
-
 
209
            }
-
 
210
        }*/
-
 
211
        .onReceive(NotificationCenter.default.publisher(for: Constants.NOTIFICATION_NAME_FCM_REGISTER_NAME))
-
 
212
        { data in
-
 
213
            if data.userInfo != nil {
-
 
214
                let userInfo = data.userInfo!
-
 
215
                let token = userInfo["token"] as? String ?? ""
-
 
216
                
-
 
217
   
-
 
218
                if !token.isEmpty {
-
 
219
                    if appData.fcmToken != token  {
-
 
220
                            
-
 
221
                        var sync = SyncModel()
-
 
222
                        sync.data = token
-
 
223
                        sync.type = Constants.SYNC_ADAPTER_TYPE_FCM
-
 
224
                            
-
 
225
                        let syncDao = SyncDao()
-
 
226
                        if syncDao.insert(record: sync) > 0 {
-
 
227
                            appData.fcmToken = token
-
 
228
                            appData.save()
-
 
229
                                
-
 
230
                            let syncAdapter = SyncAdapter()
-
 
231
                            syncAdapter.sync(isForeground: true) {
-
 
232
                                success in
-
 
233
                            }
-
 
234
                        }
-
 
235
                    }
-
 
236
                }
-
 
237
            }
180
        }
238
        }
181
        .onReceive(NotificationCenter.default.publisher(for: Constants.NOTIFICATION_NAME_COMMAND_EXIT))
239
        .onReceive(NotificationCenter.default.publisher(for: Constants.NOTIFICATION_NAME_COMMAND_EXIT))
Línea -... Línea 240...
-
 
240
       { data in
-
 
241
            
-
 
242
           /*if data.userInfo != nil {
-
 
243
               let userInfo = data.userInfo!
-
 
244
               let isForeground = (Int(userInfo["is_foreground"] as? String ?? "") ?? 0) == 1
-
 
245
               
-
 
246
               if isForeground {
-
 
247
                   appData.signoutActionRequired = true
182
       { data in
248
                   appData.save()
-
 
249
               } else {
-
 
250
                   DispatchQueue.main.async {
-
 
251
                       
183
            
252
                       
184
            DispatchQueue.main.async {
253
                       
185
                appData.userUuid = ""
254
                       appData.userUuid = ""
186
                appData.userFirstname = ""
255
                       appData.userFirstname = ""
187
                appData.userLastname = ""
256
                       appData.userLastname = ""
188
                appData.userEmail = ""
257
                       appData.userEmail = ""
189
                appData.userImage = ""
258
                       appData.userImage = ""
190
                appData.refreshContentActionRequired = false
259
                       appData.refreshContentActionRequired = false
191
                appData.refreshContentMessage = ""
260
                       appData.refreshContentMessage = ""
192
                appData.refreshContentMessageShowPending = false
261
                       appData.refreshContentMessageShowPending = false
193
                appData.signoutActionRequired = false
262
                       appData.signoutActionRequired = false
194
                appData.save()
263
                       appData.save()
-
 
264
                       
-
 
265
                       appNavigation.pageActive = .goodbye
-
 
266
                       
195
                
267
                       
-
 
268
                   }
-
 
269
               }
-
 
270
               
-
 
271
           }*/
-
 
272
 
Línea 196... Línea 273...
196
                appNavigation.pageActive = .goodbye
273
           appNavigation.pageActive = .goodbye
Línea 216... Línea 293...
216
            timeFormatter.dateFormat = Constants.FORMAT_TIME_12
293
            timeFormatter.dateFormat = Constants.FORMAT_TIME_12
Línea 217... Línea 294...
217
                
294
                
218
            let dateOn = dateFormatter.string(from: now)
295
            let dateOn = dateFormatter.string(from: now)
Línea 219... Línea 296...
219
            let timeOn = timeFormatter.string(from: now)
296
            let timeOn = timeFormatter.string(from: now)
220
                
297
                
Línea 221... Línea 298...
221
            let userNotificationDao = UserNotificationDao.sharedInstance
298
            let userNotificationDao = UserNotificationDao()