Skip to content

Commit 9d05859

Browse files
author
Hevin
committed
Merge remote-tracking branch 'origin/v2-dev'
2 parents 901a8e6 + 2d43bca commit 9d05859

File tree

8 files changed

+535
-466
lines changed

8 files changed

+535
-466
lines changed

.gitignore

Lines changed: 436 additions & 428 deletions
Large diffs are not rendered by default.

Jiguang.JPush.dll

-50.5 KB
Binary file not shown.

Jiguang.JPush/Jiguang.JPush.csproj

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">netstandard1.1;netstandard1.3</TargetFrameworks>
4+
<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">netstandard1.1;netstandard1.3;net45;net46</TargetFrameworks>
55
<TargetFrameworks Condition="'$(LibraryFrameworks)'!=''">$(LibraryFrameworks)</TargetFrameworks>
66
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
77
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
@@ -11,16 +11,30 @@
1111
<Product>JPush</Product>
1212
<Copyright>MIT</Copyright>
1313
<PackageLicenseUrl></PackageLicenseUrl>
14-
<Version>1.0.11</Version>
14+
<Version>1.1.0</Version>
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
18+
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
1919
</ItemGroup>
2020

21-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
21+
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
2222
<PackageReference Include="System.Net.Http">
23-
<Version>4.3.2</Version>
23+
<Version>4.0.0</Version>
24+
</PackageReference>
25+
26+
<PackageReference Include="System.Threading">
27+
<Version>4.0.0</Version>
28+
</PackageReference>
29+
</ItemGroup>
30+
31+
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
32+
<PackageReference Include="System.Net.Http">
33+
<Version>4.1.0</Version>
34+
</PackageReference>
35+
36+
<PackageReference Include="System.Threading">
37+
<Version>4.0.0</Version>
2438
</PackageReference>
2539
</ItemGroup>
2640

Jiguang.JPush/Jiguang.JPush.sln

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
2-
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26430.16
5-
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jiguang.JPush", "Jiguang.JPush.csproj", "{876384B3-898F-4392-8E20-30A1D9E393F0}"
7-
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "..\Example\Example.csproj", "{E87821A4-FB7B-4744-8188-17C348ABCE55}"
9-
EndProject
10-
Global
11-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12-
Debug|Any CPU = Debug|Any CPU
13-
Release|Any CPU = Release|Any CPU
14-
EndGlobalSection
15-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16-
{876384B3-898F-4392-8E20-30A1D9E393F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17-
{876384B3-898F-4392-8E20-30A1D9E393F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
18-
{876384B3-898F-4392-8E20-30A1D9E393F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
19-
{876384B3-898F-4392-8E20-30A1D9E393F0}.Release|Any CPU.Build.0 = Release|Any CPU
20-
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21-
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Debug|Any CPU.Build.0 = Debug|Any CPU
22-
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Release|Any CPU.ActiveCfg = Release|Any CPU
23-
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Release|Any CPU.Build.0 = Release|Any CPU
24-
EndGlobalSection
25-
GlobalSection(SolutionProperties) = preSolution
26-
HideSolutionNode = FALSE
27-
EndGlobalSection
28-
EndGlobal
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27004.2008
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jiguang.JPush", "Jiguang.JPush.csproj", "{876384B3-898F-4392-8E20-30A1D9E393F0}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example", "..\Example\Example.csproj", "{E87821A4-FB7B-4744-8188-17C348ABCE55}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{876384B3-898F-4392-8E20-30A1D9E393F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{876384B3-898F-4392-8E20-30A1D9E393F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{876384B3-898F-4392-8E20-30A1D9E393F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{876384B3-898F-4392-8E20-30A1D9E393F0}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {D1965B1D-21CA-4A32-8ACC-8B473FC7C659}
30+
EndGlobalSection
31+
EndGlobal

Jiguang.JPush/Model/Notification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class IOS
5858
{
5959
/// <summary>
6060
/// 可以是 string,也可以是 Apple 官方定义的 alert payload 结构。
61-
/// <see ="https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW5"/>
61+
/// <para><see ="https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW5"/></para>
6262
/// </summary>
6363
[JsonProperty("alert")]
6464
public object Alert { get; set; }

Jiguang.JPush/Model/PushPayload.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class PushPayload
1616
[JsonProperty("audience", DefaultValueHandling = DefaultValueHandling.Include)]
1717
public object Audience { get; set; } = "all";
1818

19-
[JsonProperty("notification")]
19+
[JsonProperty("notification", NullValueHandling = NullValueHandling.Ignore)]
2020
public Notification Notification { get; set; }
2121

2222
[JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)]

Jiguang.JPush/ReportClient.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using Jiguang.JPush.Model;
2+
using Newtonsoft.Json.Linq;
23
using System;
34
using System.Collections.Generic;
45
using System.Net.Http;
6+
using System.Text;
57
using System.Threading.Tasks;
68

79
namespace Jiguang.JPush
@@ -36,6 +38,48 @@ public HttpResponse GetMessageReport(List<string> msgIdList)
3638
return task.Result;
3739
}
3840

41+
/// <summary>
42+
/// <see cref="GetMessageSendStatus(string, List{string}, string)"/>
43+
/// </summary>
44+
public async Task<HttpResponse> GetMessageSendStatusAsync(string msgId, List<string> registrationIdList, string data)
45+
{
46+
if (string.IsNullOrEmpty(msgId))
47+
throw new ArgumentNullException(nameof(msgId));
48+
49+
if (registrationIdList == null)
50+
throw new ArgumentNullException(nameof(registrationIdList));
51+
52+
JObject body = new JObject
53+
{
54+
{ "msg_id", long.Parse(msgId) },
55+
{ "registration_ids", JArray.FromObject(registrationIdList) }
56+
};
57+
58+
if (!string.IsNullOrEmpty(data))
59+
body.Add("data", data);
60+
61+
var url = BASE_URL + "/status/message";
62+
var httpContent = new StringContent(body.ToString(), Encoding.UTF8);
63+
64+
HttpResponseMessage msg = await JPushClient.HttpClient.PostAsync(url, httpContent).ConfigureAwait(false);
65+
var content = await msg.Content.ReadAsStringAsync().ConfigureAwait(false);
66+
return new HttpResponse(msg.StatusCode, msg.Headers, content);
67+
}
68+
69+
/// <summary>
70+
/// 查询指定消息的送达状态。
71+
/// <para><see cref="https://docs.jiguang.cn/jpush/server/push/rest_api_v3_report/#_7"/></para>
72+
/// </summary>
73+
/// <param name="msgId">待查询消息的 Message Id。</param>
74+
/// <param name="registrationIdList">收到消息设备的 Registration Id 列表。</param>
75+
/// <param name="data">待查询日期,格式为 yyyy-MM-dd。如果传 null,则默认为当天。</param>
76+
public HttpResponse GetMessageSendStatus(string msgId, List<string> registrationIdList, string data)
77+
{
78+
Task<HttpResponse> task = Task.Run(() => GetMessageSendStatusAsync(msgId, registrationIdList, data));
79+
task.Wait();
80+
return task.Result;
81+
}
82+
3983
/// <summary>
4084
/// <see cref="GetMessageDetailReport(List{string})"/>
4185
/// </summary>

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# JPush Library for .NET
22

3-
[![NuGet](https://img.shields.io/badge/NuGet-v1.0.11-blue.svg)](https://preview.nuget.org/packages/Jiguang.JPush/)
3+
[![NuGet](https://img.shields.io/badge/NuGet-v1.1.0-blue.svg)](https://preview.nuget.org/packages/Jiguang.JPush/)
44

55
[极光](https://www.jiguang.cn/)官方支持的 JPush .NET API Client。
66

77
> 注意:**Jiguang.JPush** 为基于 .NET Standard 的重构版本,API 用法有较大改变,不兼容旧版本(**cn.jpush.api**),升级前请注意。
88
9+
项目中的 Example 为 .NET Core 控制台应用。
10+
911
## Install
1012

1113
- [NuGet](https://preview.nuget.org/packages/Jiguang.JPush/)
12-
- 手动添加 Jiguang.JPush.dll 依赖(在运行时可能会提示缺少其他的依赖,可根据提示安装)。
1314

1415
## Documents
1516

@@ -29,7 +30,6 @@
2930

3031
1.如果调用异步方法时出现死锁,即一直没有返回 [HttpResponse](https://github.com/jpush/jsms-api-csharp-client/blob/v2-dev/Jiguang.JSMS/Model/HttpResponse.cs),可参考这篇[文章](https://blogs.msdn.microsoft.com/jpsanders/2017/08/28/asp-net-do-not-use-task-result-in-main-context/)
3132

32-
3333
## Contribute
3434

3535
Please contribute! [Look at the issues](https://github.com/jpush/jpush-api-csharp-client/issues).

0 commit comments

Comments
 (0)