Skip to content

Commit

Permalink
support hmos
Browse files Browse the repository at this point in the history
  • Loading branch information
jg-json committed Oct 9, 2024
1 parent cf5a446 commit dcc1fa0
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 20 deletions.
6 changes: 6 additions & 0 deletions Example/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
33 changes: 29 additions & 4 deletions Example/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
using Jiguang.JPush.Model;
using System.Collections.Generic;


namespace Example
{
class Example
{
private static JPushClient client = new JPushClient(ExampleConfig.APP_KEY, ExampleConfig.MASTER_SECRET);
public const string APP_KEY = "Your AppKey";
public const string MASTER_SECRET = "Your MasterSecret";

private static JPushClient client = new JPushClient(APP_KEY, MASTER_SECRET);

public static void Main(string[] args)
{
Expand All @@ -26,7 +30,7 @@ private static void ExecutePushExample()
{
PushPayload pushPayload = new PushPayload()
{
Platform = new List<string> { "android", "ios" },
Platform = new List<string> { "android", "ios", "hmos"},
Audience = "all",
Notification = new Notification
{
Expand All @@ -40,6 +44,15 @@ private static void ExecutePushExample()
{
Alert = "ios alert",
Badge = "+1"
},

HMOS = new HMOS
{
Alert = "hmos alert",
Title = "title",
Category = "IM",
BadgeAddNum = 1,
ReceiptId = "abc1212"
}
},
Message = new Message
Expand All @@ -64,7 +77,7 @@ private static void ExecuteBatchPushExample()
{
SinglePayload singlePayload = new SinglePayload()
{
Platform = new List<string> { "android", "ios" },
Platform = new List<string> { "android", "ios", "hmos" },
Target = "flink",
Notification = new Notification
{
Expand All @@ -78,7 +91,19 @@ private static void ExecuteBatchPushExample()
{
Alert = "ios alert",
Badge = "+1"
}
},
HMOS = new HMOS
{
Alert = "hmos alert",
Title = "title",
Category = "IM",
BadgeAddNum = 1,
ReceiptId = "abc1212",
//Intent = new Dictionary<string, string>
//{
//["url"] = "scheme://test?key1=val1&key2=val2"
}
// }
},
Message = new Message
{
Expand Down
59 changes: 53 additions & 6 deletions Example/Example.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,59 @@
<Project Sdk="Microsoft.NET.Sdk">

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{462B1F04-CB30-4E04-9E3D-5158E6EDF128}</ProjectGuid>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<RootNamespace>Example</RootNamespace>
<AssemblyName>Example</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Example.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Jiguang.JPush\Jiguang.JPush.csproj" />
<ProjectReference Include="..\Jiguang.JPush\Jiguang.JPush.csproj">
<Project>{a182f843-fcac-4497-8006-32541dc772f4}</Project>
<Name>Jiguang.JPush</Name>
</ProjectReference>
</ItemGroup>

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
31 changes: 31 additions & 0 deletions Example/Example.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.34112.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example.csproj", "{462B1F04-CB30-4E04-9E3D-5158E6EDF128}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jiguang.JPush", "..\Jiguang.JPush\Jiguang.JPush.csproj", "{A182F843-FCAC-4497-8006-32541DC772F4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{462B1F04-CB30-4E04-9E3D-5158E6EDF128}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{462B1F04-CB30-4E04-9E3D-5158E6EDF128}.Debug|Any CPU.Build.0 = Debug|Any CPU
{462B1F04-CB30-4E04-9E3D-5158E6EDF128}.Release|Any CPU.ActiveCfg = Release|Any CPU
{462B1F04-CB30-4E04-9E3D-5158E6EDF128}.Release|Any CPU.Build.0 = Release|Any CPU
{A182F843-FCAC-4497-8006-32541DC772F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A182F843-FCAC-4497-8006-32541DC772F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A182F843-FCAC-4497-8006-32541DC772F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A182F843-FCAC-4497-8006-32541DC772F4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7E6535B3-8F76-4D64-833B-5A4B8CB18205}
EndGlobalSection
EndGlobal
10 changes: 0 additions & 10 deletions Example/ExampleConfig.cs.example

This file was deleted.

36 changes: 36 additions & 0 deletions Example/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Example")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Example")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]

// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("462b1f04-cb30-4e04-9e3d-5158e6edf128")]

// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
53 changes: 53 additions & 0 deletions Jiguang.JPush/Model/Notification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class Notification

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

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

public class Android
Expand Down Expand Up @@ -117,4 +120,54 @@ public class IOS
[JsonProperty("thread-id", NullValueHandling = NullValueHandling.Ignore)]
public string ThreadId { get; set; }
}

public class HMOS
{
/// <summary>
/// 必填。
/// </summary>
[JsonProperty("alert")]
public string Alert { get; set; }

[JsonProperty("title", NullValueHandling = NullValueHandling.Ignore)]
public string Title { get; set; }

[JsonProperty("category")]
public string Category { get; set; }

[JsonProperty("large_icon", NullValueHandling = NullValueHandling.Ignore)]
public string LargeIcon { get; set; }

[JsonProperty("intent", NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<string, object> Intent { get; set; }

[JsonProperty("badge_add_num", NullValueHandling = NullValueHandling.Ignore)]
public int? BadgeAddNum { get; set; }

[JsonProperty("badge_set_num", NullValueHandling = NullValueHandling.Ignore)]
public int? BadgeSetNum { get; set; }

[JsonProperty("test_message", NullValueHandling = NullValueHandling.Ignore)]
public bool? TestMessage { get; set; }

[JsonProperty("receipt_id", NullValueHandling = NullValueHandling.Ignore)]
public string ReceiptId { get; set; }

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

[JsonProperty("style", NullValueHandling = NullValueHandling.Ignore)]
public int? Style { get; set; }

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

[JsonProperty("push_type", NullValueHandling = NullValueHandling.Ignore)]
public int? PushType { get; set; }

[JsonProperty("extra_data", NullValueHandling = NullValueHandling.Ignore)]
public string ExtraData { get; set; }

}

}

0 comments on commit dcc1fa0

Please sign in to comment.