public void Send_Notifications_To_Not_Answered() { if (not_voted != null) { foreach (User.User_Information user in not_voted) { Send(user); } void Send(User.User_Information user) { Firebase_Handler.Send_Notification(new Firebase_Handler.FCM_Params() { User_Id = user.Id, Title = "", Body = "¡Hola " + user.Name + "! \n" + "Aún no hemos registrado ningun voto tuyo a la encuesta o el evento '" + votable.Title + "'. " + "Éste es un recordatorio cordial por parte de tod@s de que votes en cuanto puedas. ¡Un saludo!", Data_Pairs = new Dictionary <string, string>() { { "Load_type", Database_Handler.Selected_Data.GetType().ToString() }, { "Load_id", votable.Id.ToString() } } }); } } }
public void Confirm_Send_Notification() { if (User.User_Info.Role >= User.User_Role.moderator) { Dictionary <string, string> data_pairs = new Dictionary <string, string>(); switch (message_type) { case Message_Type.Copy_Notification: data_pairs.Add("Msg_Title", title.text); data_pairs.Add("Msg_Content", body.text); break; case Message_Type.Custom: data_pairs.Add("Msg_Title", title_message.text); data_pairs.Add("Msg_Content", body_message.text); break; } if (redirect_type != Redirect_Type.No_Redirect) { data_pairs.Add("Red_Type", redirect_type.ToString()); data_pairs.Add("Red_Id", redirect_id.text); } List <string> success = new List <string>(); List <string> no_device = new List <string>(); List <string> unknown = new List <string>(); foreach (User.User_Information info in searcher.Targets) { Firebase_Handler.Send_Notification(new Firebase_Handler.FCM_Params() { User_Id = info.Id, Title = title.text, Body = body.text, Data_Pairs = data_pairs, Concluding_Method = (object[] data) => { if ((string)data[2] == "0") { success.Add(info.Username); } else if ((string)data[2] == "-1" && (string)data[1] == "notification_key not found") { no_device.Add(info.Username); } else { unknown.Add(info.Username); } if (success.Count + no_device.Count + unknown.Count >= searcher.Targets.Count) { string message = ""; if (success.Count > 0) { message += "Éxito: " + Utils.List_To_String(success, ", ") + ". "; } if (no_device.Count > 0) { message += "Sin registrar: " + Utils.List_To_String(no_device, ", ") + ". "; } if (unknown.Count > 0) { message += "Error: " + Utils.List_To_String(unknown, ", ") + "."; } Debug.Log(message); Message.ShowMessage(message); } } }); } title.text = ""; body.text = ""; title_message.text = ""; body_message.text = ""; redirect_id.text = ""; } else { Message.ShowMessage(not_permitted_message); } }