                 
             }
             
-            if let networkUuid = options["networkUuid"], apiKey = options["apiKey"] {
-                let tokenSign = JWT.encode(["networkUuid": networkUuid], algorithm: .HS256(apiKey))
+            if let uuid = options["uuid"], apiKey = options["apiKey"] {
+                let tokenSign = JWT.encode(["uuid": uuid, "type": "consumerApp"], algorithm: .HS256(apiKey))
+                login(["token":tokenSign]).then {(auth: Auth) -> Void  in
+                    self.initNetwork(auth)
+                    if self.enableSocket {
+                        socketManager.start_socket().then { (result: Bool) -> Void  in
+                            if result{
+                                fulfill(true)
+                            }
+                        }
+                    }
+                }
+            }
+            
+            if let uuid = options["consumerAppUuid"], apiKey = options["apiKey"] {
+                let tokenSign = JWT.encode(["uuid": uuid, "type": "consumerApp"], algorithm: .HS256(apiKey))
+                login(["token":tokenSign]).then {(auth: Auth) -> Void  in
+                    self.initNetwork(auth)
+                    if self.enableSocket {
+                        socketManager.start_socket().then { (result: Bool) -> Void  in
+                            if result{
+                                fulfill(true)
+                            }
+                        }
+                    }
+                }
+            }
+            
+            if let uuid = options["networkUuid"], apiKey = options["apiKey"] {
+                let tokenSign = JWT.encode(["uuid": uuid, "type": "consumerApp"], algorithm: .HS256(apiKey))
                 login(["token":tokenSign]).then {(auth: Auth) -> Void  in
                     self.initNetwork(auth)
                     if self.enableSocket {

                }
            }
            
            if let deviceUuid = options["deviceUuid"], secret = options["secret"] {
                let tokenSign = JWT.encode(["uuid": deviceUuid], algorithm: .HS256(secret))
                login(["token":tokenSign]).then {(auth: Auth) -> Void  in
                    self.initNetwork(auth)
                    if self.enableSocket {

            }
            
            if let uuid = options["uuid"], secret = options["secret"] {
                let tokenSign = JWT.encode(["uuid": uuid, "type": "device"], algorithm: .HS256(secret))
                login(["token":tokenSign]).then {(auth: Auth) -> Void  in
                    self.initNetwork(auth)
                    if self.enableSocket {
