Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

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

Rev 9 Rev 11
Línea 12... Línea 12...
12
 
12
 
Línea 13... Línea 13...
13
//UIResponder, UIApplicationDelegate {
13
//UIResponder, UIApplicationDelegate {
14
 
14
 
15
class AppDelegate : NSObject, UIApplicationDelegate {
-
 
16
    private var isSyncInProgress = false
15
class AppDelegate : NSObject, UIApplicationDelegate {
17
    private var timer = Timer()
16
    private var isSyncInProgress = false
18
    private var syncAdapter = SyncAdapter()
17
    private var syncAdapter = SyncAdapter()
Línea 19... Línea 18...
19
    private let gcmMessageIDKey = "gcm.message_id"
18
    private let gcmMessageIDKey = "gcm.message_id"
Línea 26... Línea 25...
26
    }
25
    }
Línea 27... Línea 26...
27
    
26
    
28
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:
27
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:
Línea -... Línea 28...
-
 
28
        [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
-
 
29
 
-
 
30
        let database = Database.sharedInstance
-
 
31
        if database.open() != nil {
-
 
32
              database.createTables()
-
 
33
        }
-
 
34
        
-
 
35
        let appDao = AppDao.sharedInstance
-
 
36
        var appData = appDao.selectOne()
-
 
37
   
-
 
38
        
-
 
39
        if appData.id == 0 {
-
 
40
            appData.deviceUuid = "-"
Línea 29... Línea 41...
29
        [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
41
            appDao.insert(model: appData)
30
 
42
        }
Línea 78... Línea 90...
78
    @objc func receivingNewDevice(n: NSNotification){
90
    @objc func receivingNewDevice(n: NSNotification){
Línea 79... Línea 91...
79
 
91
 
80
            print("receivingNewDevice")
92
            print("receivingNewDevice")
81
            if n.userInfo != nil{
93
            if n.userInfo != nil{
82
                if let new_uuid = n.userInfo?["uuid"]! as? String {
-
 
-
 
94
                if let new_uuid = n.userInfo?["uuid"]! as? String {
83
                    
95
                    var appData = appDao.selectOne()
84
                    let old_uuid = appData.deviceUuid
96
                    let old_uuid = appData.deviceUuid
85
                    if new_uuid != old_uuid {
97
                    if new_uuid != old_uuid {
86
                        var sync = SyncModel()
98
                        var sync = SyncModel()
87
                        sync.type = Constants.SYNC_ADAPTER_TYPE_DEVICE
99
                        sync.type = Constants.SYNC_ADAPTER_TYPE_DEVICE
Línea 88... Línea 100...
88
                        sync.data = new_uuid
100
                        sync.data = new_uuid
89
                        
101
                        
-
 
102
                        if SyncDao.sharedInstance.insert(record: sync) > 0 {
-
 
103
                            appData.deviceUuid = new_uuid
90
                        if SyncDao.sharedInstance.insert(record: sync) > 0 {
104
                            
Línea 91... Línea 105...
91
                            appData.deviceUuid = new_uuid
105
                            print("update query : 18")
92
                            appData.save()
106
                            appDao.update(model: appData)
Línea 104... Línea 118...
104
        
118
        
105
        @objc func receivingNewToken(n: NSNotification){
119
        @objc func receivingNewToken(n: NSNotification){
106
            if n.userInfo != nil{
120
            if n.userInfo != nil{
107
                if let token = n.userInfo?["token"]! as? String {
121
                if let token = n.userInfo?["token"]! as? String {
108
                    if !token.isEmpty {
-
 
-
 
122
                    if !token.isEmpty {
109
 
123
                        var appData = appDao.selectOne()
Línea 110... Línea 124...
110
                        if appData.fcmToken != token  {
124
                        if appData.fcmToken != token  {
111
                            
125
                            
112
                            var sync = SyncModel()
126
                            var sync = SyncModel()
Línea 113... Línea 127...
113
                            sync.data = token
127
                            sync.data = token
Línea 114... Línea 128...
114
                            sync.type = Constants.SYNC_ADAPTER_TYPE_FCM
128
                            sync.type = Constants.SYNC_ADAPTER_TYPE_FCM
-
 
129
                            
-
 
130
                            if SyncDao.sharedInstance.insert(record: sync) > 0 {
115
                            
131
                            
Línea 116... Línea 132...
116
                            if SyncDao.sharedInstance.insert(record: sync) > 0 {
132
                                appData.fcmToken = token
117
                            
133
                                
118
                                appData.fcmToken = token
134
                                print("update query : 19")
119
                                appData.save()
135
                                appDao.update(model: appData)