// // MessageWithPayLoad.cs // // Author: // paul <> // // Copyright (c) 2015 paul // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . using System; using System.Web.Mvc; namespace Yavsc.Model.Google { // https://gcm-http.googleapis.com/gcm/send /// /// Message with payload. /// public class MessageWithPayload { /// /// To. /// public string to; /// /// The registration identifiers. /// public string [] registration_ids; /// /// The data. /// public T[] data ; /// /// The notification. /// public Notification notification; /// /// The collapse key. /// public string collapse_key; // in order to collapse ... /// /// The priority. /// public int priority; // between 0 and 10, 10 is the lowest! /// /// The content available. /// public bool content_available; /// /// The delay while idle. /// public bool delay_while_idle; /// /// The time to live. /// public int time_to_live; // seconds /// /// The name of the restricted package. /// public string restricted_package_name; /// /// The dry run. /// public bool dry_run; /// /// Validate the specified modelState. /// /// Model state. public void Validate(ModelStateDictionary modelState) { if (to==null && registration_ids == null) { modelState.AddModelError ("to", "One of \"to\" or \"registration_ids\" parameters must be specified"); modelState.AddModelError ("registration_ids", "*"); } if (notification == null && data == null) { modelState.AddModelError ("notification", "At least one of \"notification\" or \"data\" parameters must be specified"); modelState.AddModelError ("data", "*"); } if (notification != null) { if (notification.icon == null) modelState.AddModelError ("notification.icon", "please, specify an icon resoure name"); if (notification.title == null) modelState.AddModelError ("notification.title", "please, specify a title"); } } } }