application/modules/api_v1/models/Auth_model.php
//End Function users social signup/login
End Function users social signup/login
End Function users social signup / login
function updateDeviceInfo($userId,$data,$headerInfo){
        $device_ID = $this->get_device_info(USER_DEVICES, array('device_id' => $headerInfo['device-id']));
        if($device_ID !== FALSE || !empty($device_ID)){
            $this->common_model->deleteData(USER_DEVICES, array('device_id' => $headerInfo['device-id']));
        }
        $device_exist = $this->deviceExist($userId,$headerInfo['device-type'],$headerInfo['device-id']);
        if(isset($headerInfo['device_token']) && !empty($headerInfo['device_token'])){
            $data['device_token']  =  $headerInfo['device_token']; 
        }
        if($device_exist === TRUE) { 
            $update['device_token'] = $data['device_token'];
            $update['device_timezone'] = $headerInfo['device-timezone'];
            $update['updated_at'] = datetime();
            $update_device = $this->common_model->updateFields(USER_DEVICES,$update,array('device_id' => $headerInfo['device-id']));
        }else{
            $device_info = array(
                'user_id' =>$userId,
                'device_type' =>$headerInfo['device-type'],
                'device_id' => $headerInfo['device-id'],
                'device_token' =>$data['device_token'],
                'device_timezone' =>$headerInfo['device-timezone'],
                'created_at' =>datetime(),
                'updated_at' =>datetime()
            );
            $add_device = $this->common_model->insertData(USER_DEVICES,$device_info);
            if(!$add_device){
                return FALSE;
            }
        }
        return TRUE;
    }
function updateDeviceInfo ( $ userId , $ data , $ headerInfo ) { $ device_ID = $ this -> get_device_info ( USER_DEVICES , array ( 'device_id' => $ headerInfo [ 'device-id' ] ) ) ; if ( $ device_ID !== FALSE || ! empty ( $ device_ID ) ) { $ this -> common_model -> deleteData ( USER_DEVICES , array ( 'device_id' => $ headerInfo [ 'device-id' ] ) ) ; } $ device_exist = $ this -> deviceExist ( $ userId , $ headerInfo [ 'device-type' ] , $ headerInfo [ 'device-id' ] ) ; if ( isset ( $ headerInfo [ 'device_token' ] ) && ! empty ( $ headerInfo [ 'device_token' ] ) ) { $ data [ 'device_token' ] = $ headerInfo [ 'device_token' ] ; } if ( $ device_exist === TRUE ) { $ update [ 'device_token' ] = $ data [ 'device_token' ] ; $ update [ 'device_timezone' ] = $ headerInfo [ 'device-timezone' ] ; $ update [ 'updated_at' ] = datetime ( ) ; $ update_device = $ this -> common_model -> updateFields ( USER_DEVICES , $ update , array ( 'device_id' => $ headerInfo [ 'device-id' ] ) ) ; } else { $ device_info = array ( 'user_id' => $ userId , 'device_type' => $ headerInfo [ 'device-type' ] , 'device_id' => $ headerInfo [ 'device-id' ] , 'device_token' => $ data [ 'device_token' ] , 'device_timezone' => $ headerInfo [ 'device-timezone' ] , 'created_at' => datetime ( ) , 'updated_at' => datetime ( ) ) ; $ add_device = $ this -> common_model -> insertData ( USER_DEVICES , $ device_info ) ; if ( ! $ add_device ) { return FALSE ; } } return TRUE ; }
End Function users social signup/login
End Function users social signup / login
//Check device ID is already exist in DB If not empty then delete //assign device token in data array //Update device info //Insert device info