Skip to content

Commit a720561

Browse files
author
Hevin
committed
Merge branch 'v2-dev'
2 parents 0d16e0f + 996a461 commit a720561

File tree

5 files changed

+45
-31
lines changed

5 files changed

+45
-31
lines changed

Jiguang.JPush/Jiguang.JPush.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<Copyright>MIT</Copyright>
1313
<PackageLicenseUrl></PackageLicenseUrl>
1414
<PackageProjectUrl>https://github.com/jpush/jpush-api-csharp-client</PackageProjectUrl>
15-
<Version>1.1.2</Version>
15+
<Version>1.1.3</Version>
1616
</PropertyGroup>
1717

1818
<ItemGroup>

Jiguang.JPush/Model/Notification.cs

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,56 +20,60 @@ public class Notification
2020

2121
public class Android
2222
{
23+
/// <summary>
24+
/// 必填。
25+
/// </summary>
2326
[JsonProperty("alert")]
2427
public string Alert { get; set; }
2528

26-
[JsonProperty("title")]
29+
[JsonProperty("title", NullValueHandling = NullValueHandling.Ignore)]
2730
public string Title { get; set; }
2831

29-
[JsonProperty("builder_id")]
30-
public int BuilderId { get; set; }
32+
[JsonProperty("builder_id", NullValueHandling = NullValueHandling.Ignore)]
33+
public int? BuilderId { get; set; }
3134

32-
[JsonProperty("priority")]
33-
public int Priority { get; set; }
35+
[JsonProperty("priority", NullValueHandling = NullValueHandling.Ignore)]
36+
public int? Priority { get; set; }
3437

35-
[JsonProperty("category")]
38+
[JsonProperty("category", NullValueHandling = NullValueHandling.Ignore)]
3639
public string Category { get; set; }
3740

38-
[JsonProperty("style")]
39-
public int Style { get; set; }
41+
[JsonProperty("style", NullValueHandling = NullValueHandling.Ignore)]
42+
public int? Style { get; set; }
4043

41-
[JsonProperty("alert_type")]
42-
public int AlertType { get; set; }
44+
[JsonProperty("alert_type", NullValueHandling = NullValueHandling.Ignore)]
45+
public int? AlertType { get; set; }
4346

44-
[JsonProperty("big_text")]
47+
[JsonProperty("big_text", NullValueHandling = NullValueHandling.Ignore)]
4548
public string BigText { get; set; }
4649

47-
[JsonProperty("inbox")]
50+
[JsonProperty("inbox", NullValueHandling = NullValueHandling.Ignore)]
4851
public Dictionary<string, object> Inbox { get; set; }
4952

50-
[JsonProperty("big_pic_path")]
53+
[JsonProperty("big_pic_path", NullValueHandling = NullValueHandling.Ignore)]
5154
public string BigPicturePath { get; set; }
5255

53-
[JsonProperty("extras")]
56+
[JsonProperty("extras", NullValueHandling = NullValueHandling.Ignore)]
5457
public Dictionary<string, object> Extras { get; set; }
5558

5659
// VIP only - start
60+
5761
/// <summary>
5862
/// (VIP only)指定开发者想要打开的 Activity,值为 <activity> 节点的 "android:name" 属性值。
5963
/// </summary>
60-
[JsonProperty("url_activity")]
64+
[JsonProperty("url_activity", NullValueHandling = NullValueHandling.Ignore)]
6165
public string URLActivity { get; set; }
6266

6367
/// <summary>
6468
/// (VIP only)指定打开 Activity 的方式,值为 Intent.java 中预定义的 "access flags" 的取值范围。
6569
/// </summary>
66-
[JsonProperty("url_flag")]
70+
[JsonProperty("url_flag", NullValueHandling = NullValueHandling.Ignore)]
6771
public string URLFlag { get; set; }
6872

6973
/// <summary>
7074
/// (VIP only)指定开发者想要打开的 Activity,值为 <activity> -> <intent-filter> -> <action> 节点中的 "android:name" 属性值。
7175
/// </summary>
72-
[JsonProperty("uri_action")]
76+
[JsonProperty("uri_action", NullValueHandling = NullValueHandling.Ignore)]
7377
public string URIAction { get; set; }
7478

7579
// VIP only - end
@@ -84,22 +88,25 @@ public class IOS
8488
[JsonProperty("alert")]
8589
public object Alert { get; set; }
8690

87-
[JsonProperty("sound")]
91+
[JsonProperty("sound", NullValueHandling = NullValueHandling.Ignore)]
8892
public string Sound { get; set; }
8993

94+
/// <summary>
95+
/// 默认角标 +1。
96+
/// </summary>
9097
[JsonProperty("badge")]
9198
public string Badge { get; set; } = "+1";
9299

93-
[JsonProperty("content-available")]
94-
public bool ContentAvailable { get; set; }
100+
[JsonProperty("content-available", NullValueHandling = NullValueHandling.Ignore)]
101+
public bool? ContentAvailable { get; set; }
95102

96-
[JsonProperty("mutable-content")]
97-
public bool MutableContent { get; set; }
103+
[JsonProperty("mutable-content", NullValueHandling = NullValueHandling.Ignore)]
104+
public bool? MutableContent { get; set; }
98105

99-
[JsonProperty("category")]
106+
[JsonProperty("category", NullValueHandling = NullValueHandling.Ignore)]
100107
public string Category { get; set; }
101108

102-
[JsonProperty("extras")]
109+
[JsonProperty("extras", NullValueHandling = NullValueHandling.Ignore)]
103110
public Dictionary<string, object> Extras { get; set; }
104111
}
105112
}

Jiguang.JPush/Model/Trigger.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Newtonsoft.Json;
2-
using System;
32
using System.Collections.Generic;
43

54
namespace Jiguang.JPush.Model

Jiguang.JPush/ScheduleClient.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Newtonsoft.Json.Linq;
55
using System.Net.Http;
66
using System.Text;
7+
using Newtonsoft.Json;
78

89
namespace Jiguang.JPush
910
{
@@ -14,6 +15,11 @@ public class ScheduleClient
1415

1516
private string BASE_URL = BASE_URL_SCHEDULE_DEFAULT;
1617

18+
private JsonSerializer jsonSerializer = new JsonSerializer
19+
{
20+
NullValueHandling = NullValueHandling.Ignore
21+
};
22+
1723
/// <summary>
1824
/// 设置 Schedule API 的调用地址。
1925
/// </summary>
@@ -59,7 +65,7 @@ public async Task<HttpResponse> CreateSingleScheduleTaskAsync(string name, PushP
5965
{
6066
["name"] = name,
6167
["enabled"] = true,
62-
["push"] = JObject.FromObject(pushPayload),
68+
["push"] = JObject.FromObject(pushPayload, jsonSerializer),
6369
["trigger"] = new JObject
6470
{
6571
["single"] = new JObject
@@ -103,7 +109,7 @@ public async Task<HttpResponse> CreatePeriodicalScheduleTaskAsync(string name, P
103109
{
104110
["name"] = name,
105111
["enabled"] = true,
106-
["push"] = JObject.FromObject(pushPayload),
112+
["push"] = JObject.FromObject(pushPayload, jsonSerializer),
107113
["trigger"] = new JObject()
108114
{
109115
["periodical"] = JObject.FromObject(trigger)
@@ -227,7 +233,7 @@ public async Task<HttpResponse> UpdateSingleScheduleTaskAsync(string scheduleId,
227233

228234
if (pushPayload != null)
229235
{
230-
json["push"] = JObject.FromObject(pushPayload);
236+
json["push"] = JObject.FromObject(pushPayload, jsonSerializer);
231237
}
232238

233239
return await UpdateScheduleTaskAsync(scheduleId, json.ToString()).ConfigureAwait(false);
@@ -269,13 +275,13 @@ public async Task<HttpResponse> UpdatePeriodicalScheduleTaskAsync(string schedul
269275
{
270276
json["trigger"] = new JObject
271277
{
272-
["periodical"] = JObject.FromObject(trigger)
278+
["periodical"] = JObject.FromObject(trigger, jsonSerializer)
273279
};
274280
}
275281

276282
if (pushPayload != null)
277283
{
278-
json["push"] = JObject.FromObject(pushPayload);
284+
json["push"] = JObject.FromObject(pushPayload, jsonSerializer);
279285
}
280286

281287
return await UpdateScheduleTaskAsync(scheduleId, json.ToString()).ConfigureAwait(false);

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
99
项目中的 Example 为 .NET Core 控制台应用。
1010

11+
开发工具:Visual Studio 2017。
12+
1113
## Install
1214

1315
- [NuGet](https://preview.nuget.org/packages/Jiguang.JPush/)

0 commit comments

Comments
 (0)