public async Task <string> GetChatActivity(string userid, string session)
        {
            try
            {
                #region Client Respone

                using (var client = new HttpClient())
                {
                    var formContent = new FormUrlEncodedContent(new[]
                    {
                        new KeyValuePair <string, string>("user_id", Settings.User_id),
                        new KeyValuePair <string, string>("user_profile_id", Settings.User_id),
                        new KeyValuePair <string, string>("s", Settings.Session),
                        new KeyValuePair <string, string>("list_type", "all")
                    });

                    var response =
                        await
                        client.PostAsync(Settings.Website + "/app_api.php?application=phone&type=get_users_list",
                                         formContent).ConfigureAwait(false);

                    response.EnsureSuccessStatusCode();
                    string json = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                    var    data      = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);
                    string apiStatus = data["api_status"].ToString();

                    #endregion

                    if (apiStatus == "200")
                    {
                        // Functions.ChatList.Clear();

                        #region Respone Success

                        var    Users     = data["users"];
                        string ThemeUrl  = data["theme_url"].ToString();
                        var    users     = JObject.Parse(json).SelectToken("users").ToString();
                        Object obj       = JsonConvert.DeserializeObject(users);
                        JArray Chatusers = JArray.Parse(users);
                        if (Chatusers.Count <= 0)
                        {
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                ChatActivityListview.IsVisible = false;
                                EmptyChatPage.IsVisible        = true;
                            });

                            return(null);
                        }
                        else
                        {
                            ChatActivityListview.ItemsSource = ChatList;
                        }

                        //var ListTodelete = new ChatActivityFunctions();
                        // ListTodelete.ClearChatUserTable();
                        foreach (var ChatUser in Chatusers)
                        {
                            JObject ChatlistUserdata  = JObject.FromObject(ChatUser);
                            var     ChatUser_User_ID  = ChatlistUserdata["user_id"].ToString();
                            var     ChatUser_avatar   = ChatlistUserdata["profile_picture"].ToString();
                            var     ChatUser_name     = ChatlistUserdata["name"].ToString();
                            var     ChatUser_lastseen = ChatlistUserdata["lastseen"].ToString();
                            // var ChatUser_lastseen_Time_Text = ChatlistUserdata["lastseen_time_text"].ToString();
                            var ChatUser_verified = ChatlistUserdata["verified"].ToString();


                            JObject ChatlistuserLastMessage       = JObject.FromObject(ChatlistUserdata["last_message"]);
                            var     listuserLastMessage_Text      = ChatlistuserLastMessage["text"].ToString();
                            var     listuserLastMessage_date_time = ChatlistuserLastMessage["date_time"].ToString();
                            var     SeenCo        = ChatlistuserLastMessage["seen"].ToString();
                            var     fromId        = ChatlistuserLastMessage["from_id"].ToString();
                            var     Messageid     = ChatlistuserLastMessage["id"].ToString();
                            var     Time          = ChatlistuserLastMessage["time"].ToString();
                            var     mediaFileName = ChatlistuserLastMessage["media"].ToString();

                            listuserLastMessage_Text = Functions.DecodeString(listuserLastMessage_Text);
                            var MediafileIcon = "";
                            if (mediaFileName.Contains("soundFile"))
                            {
                                MediafileIcon = Settings.FN_SoundFileEmoji;
                            }
                            else if (mediaFileName.Contains("image"))
                            {
                                MediafileIcon = Settings.FN_ImageFileEmoji;
                            }
                            else if (mediaFileName.Contains("video"))
                            {
                                MediafileIcon = Settings.FN_VideoFileEmoji;
                            }
                            else if (mediaFileName.Contains("sticker"))
                            {
                                MediafileIcon = Settings.FN_StickerFileEmoji;
                            }


                            if (listuserLastMessage_Text == "")
                            {
                                listuserLastMessage_Text = MediafileIcon;
                            }
                            else if (listuserLastMessage_Text.Contains("{Key:"))
                            {
                                listuserLastMessage_Text = Settings.FN_ContatactFileEmoji;
                            }
                            else
                            {
                                listuserLastMessage_Text = Functions.DecodeString(listuserLastMessage_Text);
                            }

                            var color    = "Transparent";
                            var Chekicon = "false";

                            if (fromId != Settings.User_id)
                            {
                                if (SeenCo == "0")
                                {
                                    int Messageidx = Int32.Parse(Messageid);
                                    var Style      = "Text";
                                    color = Settings.UnseenMesageColor;


                                    var Exits = SQL_Commander.GetNotifiDBCredentialsById(Messageidx);
                                    if (Exits == null)
                                    {
                                        SQL_Commander.InsertNotifiDBCredentials(new NotifiDB
                                        {
                                            messageid = Messageidx,
                                            Seen      = 0
                                        });
                                    }

                                    var Exits2 = SQL_Commander.GetNotifiDBCredentialsById(Messageidx);
                                    if (Exits2.Seen == 0 && NotifiStoper != ChatUser_User_ID)
                                    {
                                        var Iconavatr =
                                            DependencyService.Get <IPicture>()
                                            .GetPictureFromDisk(ChatUser_avatar, ChatUser_User_ID);
                                        DependencyService.Get <ILocalNotificationService>()
                                        .CreateLocalNotification(listuserLastMessage_Text, ChatUser_name,
                                                                 Iconavatr, ChatUser_User_ID, Style);
                                        Exits2.Seen = 1;
                                        SQL_Commander.UpdateNotifiDBCredentials(Exits2);
                                    }
                                }
                            }
                            else
                            {
                                if (SeenCo != "0")
                                {
                                    Chekicon = "true";
                                }
                            }

                            var Imagepath      = DependencyService.Get <IPicture>().GetPictureFromDisk(ChatUser_avatar, ChatUser_User_ID);
                            var ImageMediaFile = ImageSource.FromFile(Imagepath);

                            if (
                                DependencyService.Get <IPicture>().GetPictureFromDisk(ChatUser_avatar, ChatUser_User_ID) ==
                                "File Dont Exists")
                            {
                                ImageMediaFile = "Noprofile.png";
                                DependencyService.Get <IPicture>().SavePictureToDisk(ChatUser_avatar, ChatUser_User_ID);
                            }

                            #region Show_Online_Oflline_Icon

                            ImageSource OnlineOfflineIcon = ImageSource.FromFile("");
                            var         OnOficon          = "";
                            if (Settings.Show_Online_Oflline_Icon)
                            {
                                if (ChatUser_lastseen == "on")
                                {
                                    OnOficon          = DependencyService.Get <IPicture>().GetPictureFromDisk(ThemeUrl + "/img/windows_app/online.png", "Icons");
                                    OnlineOfflineIcon = ImageSource.FromFile(OnOficon);



                                    if (
                                        DependencyService.Get <IPicture>()
                                        .GetPictureFromDisk(ThemeUrl + "/img/windows_app/online.png", "Icons") ==
                                        "File Dont Exists")
                                    {
                                        OnlineOfflineIcon = new UriImageSource
                                        {
                                            Uri = new Uri(ThemeUrl + "/img/windows_app/online.png")
                                        };
                                        DependencyService.Get <IPicture>()
                                        .SavePictureToDisk(ThemeUrl + "/img/windows_app/online.png", "Icons");
                                    }
                                }
                                else
                                {
                                    OnOficon          = DependencyService.Get <IPicture>().GetPictureFromDisk(ThemeUrl + "/img/windows_app/offline.png", "Icons");
                                    OnlineOfflineIcon = ImageSource.FromFile(OnOficon);

                                    if (
                                        DependencyService.Get <IPicture>()
                                        .GetPictureFromDisk(ThemeUrl + "/img/windows_app/offline.png", "Icons") ==
                                        "File Dont Exists")
                                    {
                                        OnlineOfflineIcon = new UriImageSource
                                        {
                                            Uri = new Uri(ThemeUrl + "/img/windows_app/offline.png")
                                        };
                                        DependencyService.Get <IPicture>()
                                        .SavePictureToDisk(ThemeUrl + "/img/windows_app/offline.png", "Icons");
                                    }
                                }
                            }

                            #endregion

                            if (ChatUser_verified == "1")
                            {
                                ChatUser_verified = "True";
                            }
                            else
                            {
                                ChatUser_verified = "False";
                            }
                            var ChekeForNotAvailbleLabel = ChatList.FirstOrDefault(a => a.Username == "  " + "  " + "  " + AppResources.Label_NoAnyChatActivityAvailable);
                            if (ChatList.Contains(ChekeForNotAvailbleLabel))
                            {
                                ChatList.Remove(ChekeForNotAvailbleLabel);
                            }

                            var Cheke = ChatList.FirstOrDefault(a => a.UserID == ChatUser_User_ID);
                            if (ChatList.Contains(Cheke))
                            {
                                //Cheke for online/offline Status
                                if (Cheke.OnOficon != OnOficon)
                                {
                                    Cheke.OnOficon = OnOficon;
                                    Cheke.lastseen = OnlineOfflineIcon;
                                }

                                if (Cheke.TextMessage != listuserLastMessage_Text)
                                {
                                    var q = ChatList.IndexOf(ChatList.Where(X => X.UserID == ChatUser_User_ID).FirstOrDefault());
                                    if (q > -1)
                                    {
                                        Cheke.TextMessage = listuserLastMessage_Text;
                                        Cheke.Username    = ChatUser_name;
                                        Cheke.TimeLong    = Time;
                                        ChatList.Move(q, 0);
                                    }
                                }
                                //Change  User image if the user changed his avatar picture
                                if (Cheke.profile_picture_Url != Imagepath)
                                {
                                    Cheke.profile_picture_Url = Imagepath;
                                    Cheke.profile_picture     = ImageMediaFile;
                                }
                                if (Cheke.SeenMessageOrNo != color || Cheke.LastMessageDateTime != listuserLastMessage_date_time)
                                {
                                    Cheke.SeenMessageOrNo     = color;
                                    Cheke.LastMessageDateTime = listuserLastMessage_date_time;
                                }
                                if (Cheke.ChekeSeen != Chekicon)
                                {
                                    Cheke.ChekeSeen = Chekicon;
                                }
                            }
                            else
                            {
                                ChatList.Insert(0, new ChatUsers()
                                {
                                    Username            = ChatUser_name,
                                    lastseen            = OnlineOfflineIcon,
                                    profile_picture     = ImageMediaFile,
                                    TextMessage         = listuserLastMessage_Text,
                                    LastMessageDateTime = listuserLastMessage_date_time,
                                    UserID              = ChatUser_User_ID,
                                    SeenMessageOrNo     = color,
                                    ChekeSeen           = Chekicon,
                                    OnOficon            = OnOficon,
                                    TimeLong            = Time,
                                    profile_picture_Url = Imagepath,
                                    Isverifyed          = ChatUser_verified
                                });
                            }


                            var contact = SQL_Commander.GetChatUser(ChatUser_User_ID);
                            if (contact != null)
                            {
                                if (contact.UserID == ChatUser_User_ID &
                                    ((contact.Name != ChatUser_name) || (contact.ProfilePicture != ChatUser_avatar) ||
                                     (contact.Username != ChatUser_name) || (contact.ChekeSeen != Chekicon) ||
                                     (contact.SeenMessageOrNo != color) || (contact.Isverifyed != ChatUser_verified) || (contact.TimeLong != Time)))
                                {
                                    if ((contact.ProfilePicture != ChatUser_avatar))
                                    {
                                        if (Settings.Delete_Old_Profile_Picture_From_Phone)
                                        {
                                            DependencyService.Get <IPicture>().DeletePictureFromDisk(contact.ProfilePicture, ChatUser_User_ID);
                                        }
                                    }

                                    contact.UserID = ChatUser_User_ID;
                                    contact.LastMessageDateTime = listuserLastMessage_date_time;
                                    contact.Name            = ChatUser_name;
                                    contact.ProfilePicture  = ChatUser_avatar;
                                    contact.SeenMessageOrNo = color;
                                    contact.TextMessage     = listuserLastMessage_Text;
                                    contact.Username        = ChatUser_name;
                                    contact.ChekeSeen       = Chekicon;
                                    contact.TimeLong        = Time;
                                    contact.Isverifyed      = ChatUser_verified;
                                    SQL_Commander.UpdateChatUsers(contact);
                                }
                            }
                            else
                            {
                                SQL_Commander.InsertChatUsers(new ChatActivityDB()
                                {
                                    UserID = ChatUser_User_ID,
                                    LastMessageDateTime = listuserLastMessage_date_time,
                                    Name            = ChatUser_name,
                                    ProfilePicture  = ChatUser_avatar,
                                    SeenMessageOrNo = color,
                                    TextMessage     = listuserLastMessage_Text,
                                    Username        = ChatUser_name,
                                    ChekeSeen       = Chekicon,
                                    TimeLong        = Time,
                                    Isverifyed      = ChatUser_verified,
                                    lastseen        = OnlineOfflineIcon.ToString()
                                });
                            }
                        }


                        #endregion
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            if (ChatActivityListview.IsVisible == false)
                            {
                                ChatActivityListview.IsVisible = true;
                                EmptyChatPage.IsVisible        = false;
                            }
                        });
                    }
                    else if (apiStatus == "400")
                    {
                        json = AppResources.Label_Error;
                    }

                    return(json);
                }
            }
            catch (Exception)
            {
                return(AppResources.Label_Error);
            }
        }