Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v2-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hevin committed Nov 10, 2017
2 parents 901a8e6 + 2d43bca commit 9d05859
Show file tree
Hide file tree
Showing 8 changed files with 535 additions and 466 deletions.
864 changes: 436 additions & 428 deletions .gitignore

Large diffs are not rendered by default.

Binary file removed Jiguang.JPush.dll
Binary file not shown.
24 changes: 19 additions & 5 deletions Jiguang.JPush/Jiguang.JPush.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">netstandard1.1;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">netstandard1.1;netstandard1.3;net45;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(LibraryFrameworks)'!=''">$(LibraryFrameworks)</TargetFrameworks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
Expand All @@ -11,16 +11,30 @@
<Product>JPush</Product>
<Copyright>MIT</Copyright>
<PackageLicenseUrl></PackageLicenseUrl>
<Version>1.0.11</Version>
<Version>1.1.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="System.Net.Http">
<Version>4.3.2</Version>
<Version>4.0.0</Version>
</PackageReference>

<PackageReference Include="System.Threading">
<Version>4.0.0</Version>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
<PackageReference Include="System.Net.Http">
<Version>4.1.0</Version>
</PackageReference>

<PackageReference Include="System.Threading">
<Version>4.0.0</Version>
</PackageReference>
</ItemGroup>

Expand Down
59 changes: 31 additions & 28 deletions Jiguang.JPush/Jiguang.JPush.sln
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jiguang.JPush", "Jiguang.JPush.csproj", "{876384B3-898F-4392-8E20-30A1D9E393F0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "..\Example\Example.csproj", "{E87821A4-FB7B-4744-8188-17C348ABCE55}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{876384B3-898F-4392-8E20-30A1D9E393F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{876384B3-898F-4392-8E20-30A1D9E393F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{876384B3-898F-4392-8E20-30A1D9E393F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{876384B3-898F-4392-8E20-30A1D9E393F0}.Release|Any CPU.Build.0 = Release|Any CPU
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2008
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jiguang.JPush", "Jiguang.JPush.csproj", "{876384B3-898F-4392-8E20-30A1D9E393F0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example", "..\Example\Example.csproj", "{E87821A4-FB7B-4744-8188-17C348ABCE55}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{876384B3-898F-4392-8E20-30A1D9E393F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{876384B3-898F-4392-8E20-30A1D9E393F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{876384B3-898F-4392-8E20-30A1D9E393F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{876384B3-898F-4392-8E20-30A1D9E393F0}.Release|Any CPU.Build.0 = Release|Any CPU
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E87821A4-FB7B-4744-8188-17C348ABCE55}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D1965B1D-21CA-4A32-8ACC-8B473FC7C659}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion Jiguang.JPush/Model/Notification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class IOS
{
/// <summary>
/// 可以是 string,也可以是 Apple 官方定义的 alert payload 结构。
/// <see ="https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW5"/>
/// <para><see ="https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW5"/></para>
/// </summary>
[JsonProperty("alert")]
public object Alert { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Jiguang.JPush/Model/PushPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class PushPayload
[JsonProperty("audience", DefaultValueHandling = DefaultValueHandling.Include)]
public object Audience { get; set; } = "all";

[JsonProperty("notification")]
[JsonProperty("notification", NullValueHandling = NullValueHandling.Ignore)]
public Notification Notification { get; set; }

[JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)]
Expand Down
44 changes: 44 additions & 0 deletions Jiguang.JPush/ReportClient.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Jiguang.JPush.Model;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace Jiguang.JPush
Expand Down Expand Up @@ -36,6 +38,48 @@ public HttpResponse GetMessageReport(List<string> msgIdList)
return task.Result;
}

/// <summary>
/// <see cref="GetMessageSendStatus(string, List{string}, string)"/>
/// </summary>
public async Task<HttpResponse> GetMessageSendStatusAsync(string msgId, List<string> registrationIdList, string data)
{
if (string.IsNullOrEmpty(msgId))
throw new ArgumentNullException(nameof(msgId));

if (registrationIdList == null)
throw new ArgumentNullException(nameof(registrationIdList));

JObject body = new JObject
{
{ "msg_id", long.Parse(msgId) },
{ "registration_ids", JArray.FromObject(registrationIdList) }
};

if (!string.IsNullOrEmpty(data))
body.Add("data", data);

var url = BASE_URL + "/status/message";
var httpContent = new StringContent(body.ToString(), Encoding.UTF8);

HttpResponseMessage msg = await JPushClient.HttpClient.PostAsync(url, httpContent).ConfigureAwait(false);
var content = await msg.Content.ReadAsStringAsync().ConfigureAwait(false);
return new HttpResponse(msg.StatusCode, msg.Headers, content);
}

/// <summary>
/// 查询指定消息的送达状态。
/// <para><see cref="https://docs.jiguang.cn/jpush/server/push/rest_api_v3_report/#_7"/></para>
/// </summary>
/// <param name="msgId">待查询消息的 Message Id。</param>
/// <param name="registrationIdList">收到消息设备的 Registration Id 列表。</param>
/// <param name="data">待查询日期,格式为 yyyy-MM-dd。如果传 null,则默认为当天。</param>
public HttpResponse GetMessageSendStatus(string msgId, List<string> registrationIdList, string data)
{
Task<HttpResponse> task = Task.Run(() => GetMessageSendStatusAsync(msgId, registrationIdList, data));
task.Wait();
return task.Result;
}

/// <summary>
/// <see cref="GetMessageDetailReport(List{string})"/>
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# JPush Library for .NET

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

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

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

## Install

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

## Documents

Expand All @@ -29,7 +30,6 @@

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/)


## Contribute

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

0 comments on commit 9d05859

Please sign in to comment.