Skip to content

Push Kit API v2 support #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bin/
build/
obj/
.vscode/
.vs/
Expand Down
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# HMS Core Push Kit Sample Code (C#)
English | [中文](README_ZH.md)
English | [中文](./README_ZH.md)
## Contents
* [Introduction](#Introduction)
* [Installation](#Installation)
Expand All @@ -23,33 +23,53 @@ The following table describes main classes used in the sample code.
| Class Name| Description|
| ----------- | ----------- |
|AppOptions|App-related configuration.|
|ApiVersion|Push Kit API version.|
|AGConnectApp|App.|
|AGConnectMessaging|Push Kit API calling methods.|
|Message|Message body.|

## Installation

### Source code

1. Decompress the sample code.
2. Copy **AGConnectAdmin** to a proper position in your Visual Studio solution and reference the corresponding assembly in your project.
3. Use the classes in **AGConnectAdmin** by referring to the sample code.

### Local NuGet

1. Download NuGet package from Releases
2. Create *Resources* directory and move downloaded package there
3. Create **nuget.config** file at solution directory and paste
```
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="LocalNuGet" value="Resources" />
</packageSources>
</configuration>
```
4. Install package from local NuGet to target project

## Configuration

The following table describes the parameters related to the **AppOptions** class.

| Parameter| Description|
| ----------- | ----------- |
|ProjectId|Project ID, which is obtained from the project information.|
|ClientId|App ID, which is obtained from the app information.|
|ClientSecret|App secret, which is obtained from the app information.|
|LoginUri|URL for Huawei OAuth 2.0 to obtain a token. For details, please refer to [OAuth 2.0-based Authentication](https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/oauth2-0000001212610981).|
|ApiBaseUri|Access address of Push Kit. For details, please refer to [Downlink Message Sending](https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-server-dev-0000001050040110?ha_source=hms1).|
|ApiVersion|Push Kit API version. For details, please refer to [Sending Downlink Messages](https://developer.huawei.com/consumer/en/doc/HMSCore-References/https-send-api-0000001050986197).|

## Environment Requirements

The demo projects need to be opened using Visual Studio 2017 or a later version. The following framework versions are supported:

- .NET Framework 4.5 or later
- .NET Standard 2.0 or later
- .NET 6.0 or later

## Sample Code

Expand Down
24 changes: 22 additions & 2 deletions README_ZH.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 华为推送服务服务端C#示例代码
[English](README.md) | 中文
[English](./README.md) | 中文

## 目录
* [简介](#简介)
Expand All @@ -24,33 +24,53 @@ C#示例代码对华为推送服务(HUAWEI Push Kit)服务端接口进行封
| 类名 | 说明 |
| ----------- | ----------- |
|AppOptions|应用相关配置|
|ApiVersion|推送服务API版本。|
|AGConnectApp|应用|
|AGConnectMessaging|推送服务相关接口的调用方法|
|Message|消息体|

## 安装

### 源代码

1. 解压示例代码。
2. 将解压后的AGConnectAdmin复制到你的Visual Studio Solution中适当的位置,在你的应用工程中引用对应的程序集即可。
3. 参考示例代码来使用AGConnectAdmin中的类。

### 本地 NuGet

1. 从 Releases 下载 NuGet 包
2. 创建 *Resources* 目录并将下载的包移动到那里
3. 在解决方案目录中创建 **nuget.config** 文件并粘贴
```
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="LocalNuGet" value="Resources" />
</packageSources>
</configuration>
```
4. 从本地 NuGet 安装包到目标项目

## 配置

以下描述了AppOptions类的相关参数。

| 参数 | 说明 |
| ----------- | ----------- |
|ProjectId|项目ID,从项目信息中获取。|
|ClientId|应用ID,从应用信息中获取|
|ClientSecret|应用访问密钥,从应用信息中获取|
|LoginUri|华为OAuth 2.0获取token的地址。详情请参见[基于OAuth 2.0开放鉴权-客户端模式](https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/oauth2-0000001212610981#section128682386159?ha_source=hms1)。|
|ApiBaseUri|推送服务的访问地址。详情请参见[推送服务-下行消息](https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/android-server-dev-0000001050040110?ha_source=hms1)。|
|ApiVersion|推送服务API版本。 详情请参见【下行消息发送】(https://developer.huawei.com/consumer/cn/doc/HMSCore-References/https-send-api-0000001050986197)。|

## 环境要求

示例代码工程需要使用Visual Studio 2017或以上版本的开发工具打开,类库提供以下种框架版本:

- .NET Framework 4.5以上
- .NET Standard 2.0以上
- .NET 6.0以上

## 示例代码

Expand Down
63 changes: 63 additions & 0 deletions src/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
Loading