/// <summary> /// 获取通知的Json格式字符串 /// <example> /// 格式:{"n_builder_id":"通知样式","n_title":"通知标题","n_content":"通知内容", "n_extras":{"ios":{"badge":8, "sound":"happy"}, "user_param_1":"value1", "user_param_2":"value2"}} /// </example> /// </summary> /// <param name="platform">The platform.</param> /// <returns></returns> public string GetJsonString(Platform platform = Platform.Android|Platform.iOS) { IDictionary<string, object> data = new Dictionary<string, object> { { "n_title", this.Title ?? string.Empty }, { "n_content", this.Content ?? string.Empty } }; IDictionary<string, object> extra = new Dictionary<string, object>(); if (this.CustomizedValue != null) foreach (string key in this.CustomizedValue.Keys) { extra[key] = this.CustomizedValue[key]; } if (platform.Contains(Platform.Android)) { if (this.Android_BuilderId > 0 && this.Android_BuilderId <= 1000) data["n_builder_id"] = this.Android_BuilderId; } if (platform.Contains(Platform.iOS)) { IDictionary<string, object> iOSExtra = new Dictionary<string, object>(); iOSExtra["badge"] = this.iOS_Badge; if (!string.IsNullOrWhiteSpace(this.iOS_Sound)) iOSExtra["sound"] = this.iOS_Sound; extra["ios"] = iOSExtra; } data.Add("n_extras", extra); return JsonConvert.SerializeObject(data); }