Saturday, 4 May 2019

Upgrade Android/IOS App using Codeigniter Restful Webservices(API)

What is Restful Webservices :- It is nothing just a function. webservices are the api that is used to communicate with different technologies. It is also called api (Application Programming Interface) used for provide the interface between different application.

Now I would like to share webservice of upgrade app and force update app.

Here we will writeapp_version_check() webservice in codeigniter controller or any framework.

Step:1 app_version_check()webservice



public function app_version_check()
{
$os = $this->input->get_post('os');
$app = $this->input->get_post('app');
$version = $this->input->get_post('version');
if($os == '' || $app == '' || $version == '' )
{

$status="error";
$message="Please Enter Required Fields";
$response=$this->response_msg($status,$message);
}
else
{
$upgrade_required = $this->Home_model->app_version_check($os,$app,$version);

if(!isset($upgrade_required))
{
$is_upgrade_required="True";
$message="New version of connectosh Available";
$response=$this->response_msg($status,$message);
}
else
{
$is_upgrade_required="False";
$message="No Need to update";
$response=$this->response_msg($status,$message);
}

}
$this->output
->set_content_type('application/json')
->set_output(json_encode($response));

}

There are 3 parameters os,app_name,version name pass in model and get the response in json format.

Step:2 app_version_check() Model

public function app_version_check($os,$app,$version)
{

$this->db->select('*');
$this->db->from('app_info');
$this->db->where('os',$os);
$this->db->where('app_name',$app);
$this->db->where('upgrade_code',$version);
$query=$this->db->get();
return $query->row();


}

Make sure you have a database of app_info table with 3 columns name('os','app_name','upgrade_code').

Now you can test the webservices using Postman.

No comments:

Post a Comment

How to upload All type of Files on AWS S3 using Codeigniter

Upload Files on Amazon S3 Bucket using Codeigniter. Before this,Firstly You have to know about the S3 Bucket. This is the simple Storag...