C# sample code encapsulates APIs of the HUAWEI Push Kit server. It provides many sample programs for your reference or usage. The following table describes folders of C# sample code:
Folder | Description |
---|---|
AGConnectAdmin | Class library encapsulated for HUAWEI Push Kit. |
AGConnectAdmin.Examples | Examples of using the Class library. |
The following table defines main classes in the sample code:
Class | Description |
---|---|
AppOptions | App configurations. |
AGConnectApp | App. |
AGConnectMessaging | HUAWEI Push Kit API calling methods. |
Message | Body of a message. |
- Decompress the sample code.
- Copy the decompressed AGConnectAdmin project to a proper location in your app's Visual Studio Solution, and then reference the project in your app project.
- Refer to the example codes to find out how to use classes in AGConnectAdmin project.
The following table describes parameters of the AppOptions class:
Parameter | Description |
---|---|
ClientId | App ID, which is obtained from app information. |
ClientSecret | Secret access key of an app, which is obtained from app information. |
LoginUri | URL for the Huawei OAuth 2.0 service to obtain a token, please refer to Generating an App-Level Access Token. |
ApiBaseUri | URL for accessing HUAWEI Push Kit, please refer to Sending Messages. |
Sample code projects need to be opened by Visual Studio 2017 or a later version and supports the following frameworks:
- .NET Framework 4.5+
- .NET Standard 2.0+
All sample code are in AGConnectAdmin.Examples project included below use cases.
- Send an Android data message.
AGConnectAdmin.Examples/Example.SendDataMessage.cs
- Send an Android notification message.
AGConnectAdmin.Examples/Example.SendAndroidMessage.cs
- Send a message by topic.
AGConnectAdmin.Examples/Example.SendTopicMessage.cs
- Send a message by conditions.
AGConnectAdmin.Examples/Example.SendConditionMessage.cs
- Send a message to a Huawei quick app.
AGConnectAdmin.Examples/Example.SendInstanceAppMessage.cs
- Send a message through the WebPush agent.
AGConnectAdmin.Examples/Example.SendWebpushMessage.cs
- Send a message through the APNs agent.
AGConnectAdmin.Examples/Example.SendApnsMessage.cs
- Send a test message.
AGConnectAdmin.Examples/Example.SendTestMessage.cs
The sample codes are licensed under the Apache License, version 2.0.