private void SendUpdateProfilePicNotification(NotificationModel notificationModel) { ulong tempNumber; if (NeeoUtility.IsNullOrEmpty(notificationModel.SenderID) || !ulong.TryParse(notificationModel.SenderID, out tempNumber)) { throw new ApplicationException(CustomHttpStatusCode.InvalidArguments.ToString("D")); } // Get the name of the user from data base. List <NeeoUser> userRoasterList = NeeoUser.GetUserRoster(notificationModel.SenderID); if (userRoasterList.Count == 0) { return; } notificationModel.Alert = "Update"; var taskSendiOSNotification = Task.Factory.StartNew(() => { var iosUserList = userRoasterList.Where( x => x.DevicePlatform == DevicePlatform.iOS && x.PresenceStatus == Presence.Offline).ToList(); _services.ApnsService.Send(iosUserList, notificationModel); }); var taskSendAndroidNotification = Task.Factory.StartNew(() => { var androidUserList = userRoasterList.Where( x => x.DevicePlatform == DevicePlatform.Android //&& x.PresenceStatus == Presence.Offline ).ToList(); _services.GcmService.Send(androidUserList, notificationModel); }); Task.WaitAll(taskSendiOSNotification, taskSendAndroidNotification); }