Skip to content

Commit dcc1fa0

Browse files
committed
support hmos
1 parent cf5a446 commit dcc1fa0

File tree

7 files changed

+208
-20
lines changed

7 files changed

+208
-20
lines changed

Example/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
5+
</startup>
6+
</configuration>

Example/Example.cs

+29-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
using Jiguang.JPush.Model;
44
using System.Collections.Generic;
55

6+
67
namespace Example
78
{
89
class Example
910
{
10-
private static JPushClient client = new JPushClient(ExampleConfig.APP_KEY, ExampleConfig.MASTER_SECRET);
11+
public const string APP_KEY = "Your AppKey";
12+
public const string MASTER_SECRET = "Your MasterSecret";
13+
14+
private static JPushClient client = new JPushClient(APP_KEY, MASTER_SECRET);
1115

1216
public static void Main(string[] args)
1317
{
@@ -26,7 +30,7 @@ private static void ExecutePushExample()
2630
{
2731
PushPayload pushPayload = new PushPayload()
2832
{
29-
Platform = new List<string> { "android", "ios" },
33+
Platform = new List<string> { "android", "ios", "hmos"},
3034
Audience = "all",
3135
Notification = new Notification
3236
{
@@ -40,6 +44,15 @@ private static void ExecutePushExample()
4044
{
4145
Alert = "ios alert",
4246
Badge = "+1"
47+
},
48+
49+
HMOS = new HMOS
50+
{
51+
Alert = "hmos alert",
52+
Title = "title",
53+
Category = "IM",
54+
BadgeAddNum = 1,
55+
ReceiptId = "abc1212"
4356
}
4457
},
4558
Message = new Message
@@ -64,7 +77,7 @@ private static void ExecuteBatchPushExample()
6477
{
6578
SinglePayload singlePayload = new SinglePayload()
6679
{
67-
Platform = new List<string> { "android", "ios" },
80+
Platform = new List<string> { "android", "ios", "hmos" },
6881
Target = "flink",
6982
Notification = new Notification
7083
{
@@ -78,7 +91,19 @@ private static void ExecuteBatchPushExample()
7891
{
7992
Alert = "ios alert",
8093
Badge = "+1"
81-
}
94+
},
95+
HMOS = new HMOS
96+
{
97+
Alert = "hmos alert",
98+
Title = "title",
99+
Category = "IM",
100+
BadgeAddNum = 1,
101+
ReceiptId = "abc1212",
102+
//Intent = new Dictionary<string, string>
103+
//{
104+
//["url"] = "scheme://test?key1=val1&key2=val2"
105+
}
106+
// }
82107
},
83108
Message = new Message
84109
{

Example/Example.csproj

+53-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,59 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
34
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{462B1F04-CB30-4E04-9E3D-5158E6EDF128}</ProjectGuid>
48
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp1.1</TargetFramework>
9+
<RootNamespace>Example</RootNamespace>
10+
<AssemblyName>Example</AssemblyName>
11+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
615
</PropertyGroup>
7-
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Example.cs" />
47+
<Compile Include="Properties\AssemblyInfo.cs" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<None Include="App.config" />
51+
</ItemGroup>
852
<ItemGroup>
9-
<ProjectReference Include="..\Jiguang.JPush\Jiguang.JPush.csproj" />
53+
<ProjectReference Include="..\Jiguang.JPush\Jiguang.JPush.csproj">
54+
<Project>{a182f843-fcac-4497-8006-32541dc772f4}</Project>
55+
<Name>Jiguang.JPush</Name>
56+
</ProjectReference>
1057
</ItemGroup>
11-
58+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
1259
</Project>

Example/Example.sln

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.34112.143
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example.csproj", "{462B1F04-CB30-4E04-9E3D-5158E6EDF128}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jiguang.JPush", "..\Jiguang.JPush\Jiguang.JPush.csproj", "{A182F843-FCAC-4497-8006-32541DC772F4}"
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+
{462B1F04-CB30-4E04-9E3D-5158E6EDF128}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{462B1F04-CB30-4E04-9E3D-5158E6EDF128}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{462B1F04-CB30-4E04-9E3D-5158E6EDF128}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{462B1F04-CB30-4E04-9E3D-5158E6EDF128}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{A182F843-FCAC-4497-8006-32541DC772F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{A182F843-FCAC-4497-8006-32541DC772F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{A182F843-FCAC-4497-8006-32541DC772F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{A182F843-FCAC-4497-8006-32541DC772F4}.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 = {7E6535B3-8F76-4D64-833B-5A4B8CB18205}
30+
EndGlobalSection
31+
EndGlobal

Example/ExampleConfig.cs.example

-10
This file was deleted.

Example/Properties/AssemblyInfo.cs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// 有关程序集的一般信息由以下
6+
// 控制。更改这些特性值可修改
7+
// 与程序集关联的信息。
8+
[assembly: AssemblyTitle("Example")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Example")]
13+
[assembly: AssemblyCopyright("Copyright © 2024")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// 将 ComVisible 设置为 false 会使此程序集中的类型
18+
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19+
//请将此类型的 ComVisible 特性设置为 true。
20+
[assembly: ComVisible(false)]
21+
22+
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23+
[assembly: Guid("462b1f04-cb30-4e04-9e3d-5158e6edf128")]
24+
25+
// 程序集的版本信息由下列四个值组成:
26+
//
27+
// 主版本
28+
// 次版本
29+
// 生成号
30+
// 修订号
31+
//
32+
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33+
// 方法是按如下所示使用“*”: :
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

Jiguang.JPush/Model/Notification.cs

+53
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public class Notification
1616

1717
[JsonProperty("ios", NullValueHandling = NullValueHandling.Ignore)]
1818
public IOS IOS { get; set; }
19+
20+
[JsonProperty("hmos", NullValueHandling = NullValueHandling.Ignore)]
21+
public HMOS HMOS { get; set; }
1922
}
2023

2124
public class Android
@@ -117,4 +120,54 @@ public class IOS
117120
[JsonProperty("thread-id", NullValueHandling = NullValueHandling.Ignore)]
118121
public string ThreadId { get; set; }
119122
}
123+
124+
public class HMOS
125+
{
126+
/// <summary>
127+
/// 必填。
128+
/// </summary>
129+
[JsonProperty("alert")]
130+
public string Alert { get; set; }
131+
132+
[JsonProperty("title", NullValueHandling = NullValueHandling.Ignore)]
133+
public string Title { get; set; }
134+
135+
[JsonProperty("category")]
136+
public string Category { get; set; }
137+
138+
[JsonProperty("large_icon", NullValueHandling = NullValueHandling.Ignore)]
139+
public string LargeIcon { get; set; }
140+
141+
[JsonProperty("intent", NullValueHandling = NullValueHandling.Ignore)]
142+
public Dictionary<string, object> Intent { get; set; }
143+
144+
[JsonProperty("badge_add_num", NullValueHandling = NullValueHandling.Ignore)]
145+
public int? BadgeAddNum { get; set; }
146+
147+
[JsonProperty("badge_set_num", NullValueHandling = NullValueHandling.Ignore)]
148+
public int? BadgeSetNum { get; set; }
149+
150+
[JsonProperty("test_message", NullValueHandling = NullValueHandling.Ignore)]
151+
public bool? TestMessage { get; set; }
152+
153+
[JsonProperty("receipt_id", NullValueHandling = NullValueHandling.Ignore)]
154+
public string ReceiptId { get; set; }
155+
156+
[JsonProperty("extras", NullValueHandling = NullValueHandling.Ignore)]
157+
public Dictionary<string, object> Extras { get; set; }
158+
159+
[JsonProperty("style", NullValueHandling = NullValueHandling.Ignore)]
160+
public int? Style { get; set; }
161+
162+
[JsonProperty("inbox", NullValueHandling = NullValueHandling.Ignore)]
163+
public Dictionary<string, object> Inbox { get; set; }
164+
165+
[JsonProperty("push_type", NullValueHandling = NullValueHandling.Ignore)]
166+
public int? PushType { get; set; }
167+
168+
[JsonProperty("extra_data", NullValueHandling = NullValueHandling.Ignore)]
169+
public string ExtraData { get; set; }
170+
171+
}
172+
120173
}

0 commit comments

Comments
 (0)