{"id":22441330,"url":"https://github.com/hms-core/hms-push-serverdemo-go","last_synced_at":"2025-08-01T18:31:53.504Z","repository":{"id":45494959,"uuid":"266915940","full_name":"HMS-Core/hms-push-serverdemo-go","owner":"HMS-Core","description":"Golang sample code encapsulates APIs of the HUAWEI Push Kit server. It provides many sample programs for your reference or usage.","archived":false,"fork":false,"pushed_at":"2023-07-06T03:11:25.000Z","size":59,"stargazers_count":56,"open_issues_count":7,"forks_count":39,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-11-14T21:11:49.660Z","etag":null,"topics":["golang","hms","huawei","push","push-notifications","sendmessage","sever"],"latest_commit_sha":null,"homepage":"https://developer.huawei.com/consumer/cn/doc/development/HMS-Guides/push-introduction","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HMS-Core.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-26T01:28:25.000Z","updated_at":"2024-08-21T12:39:53.000Z","dependencies_parsed_at":"2024-06-18T22:39:40.983Z","dependency_job_id":"861195db-5a4f-4622-93e5-df5ca99da22c","html_url":"https://github.com/HMS-Core/hms-push-serverdemo-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HMS-Core%2Fhms-push-serverdemo-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HMS-Core%2Fhms-push-serverdemo-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HMS-Core%2Fhms-push-serverdemo-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HMS-Core%2Fhms-push-serverdemo-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HMS-Core","download_url":"https://codeload.github.com/HMS-Core/hms-push-serverdemo-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228397819,"owners_count":17913540,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","hms","huawei","push","push-notifications","sendmessage","sever"],"created_at":"2024-12-06T02:14:10.041Z","updated_at":"2024-12-06T02:14:10.600Z","avatar_url":"https://github.com/HMS-Core.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HMS Core Push Kit Sample Code (Golang)\nEnglish | [中文](README_ZH.md)\n## Contents\n * [Introduction](#Introduction)\n * [Installation](#Installation)\n * [Configuration](#Configuration)\n * [Sample Code](#Sample-Code)\n * [Technical Support](#technical-support)\n * [License](#License)\n\n## Introduction\nThe sample code for Golang encapsulates the server-side APIs of Push Kit, for your reference or direct use.\n\nThe following table describes packages of Golang sample code.\n| Package| Description|\n| ----------- | ----------- |\n|[examples](src/examples) | Sample code packages.|\n|[httpclient](src/httpclient/httpclient.go) | Package for sending network requests.|\n|[push](src/push) | Package where Push Kit server APIs are encapsulated.|\n\n## Installation\nInstall the Golang environment (Golang 1.11 or later is recommended) and decompress the Golang sample code package.\n    \nCopy **org.huawei.com** in the decompressed package to the **vendor** directory in the path specified by **GOPATH** in your project. Refresh the project to ensure that the copied file exists in the directory.\n    \n## Configuration\nStart configuration with the **Client** structure in the **push** package. Each method in the **Client** structure can be used to call an API of the Push Kit server.\nThe following table describes the method in the **Client** structure.\n| Method| Description|\n| ----------- | ----------- |\n|SendMessage|   Sends a message to a device.|\n\nTo use the functions provided by the packages in **examples**, set related parameters in [pushcommon.go](src/examples/common/pushcommon.go) in the common package.\n\nThe following table describes the parameters in [pushcommon.go](src/examples/common/pushcommon.go).\n| Parameter| Description|\n| ----------- | ----------- |\n|appId|App ID, which is obtained from the app information.|\n|appSecret|App secret, which is obtained from the app information.|\n|authUrl|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).|\n|pushUrl|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).|\n\nThe following table describes the parameters in [pushcommon.go](src/examples/common/pushcommon.go).\n| Parameter| Description|\n| ----------- | ----------- |\n|TargetTopic|Name of the topic to be subscribed to, unsubscribed from, or queried.|\n|TargetCondition|Combined condition expression for sending a message.|\n|TargetToken|Token of a target device, which is obtained from the target device.|\n|TargetTokenArray|Tokens of all target devices, which are obtained from these target devices.|\n\n## Sample Code\n\n1). Send an Android data message.\nYou can obtain the initialized MessageRequest instance of the data message using the NewTransparentMsgRequest method in the push/model package.\n\u003e Code location: [send_data_message](src/examples/send_data_message/main.go)\n    \n2). Send an Android notification message.\nYou can obtain the initialized MessageRequest instance of the notification message using the NewNotificationMsgRequest method in the push/model package.\n\u003e Code location: [send_notify_message](src/examples/send_notify_message/main.go)\n    \n3). Send a message by topic.\nYou can send a notification message or data message to a device by topic. Specify the topic after obtaining the MessageRequest instance.\n\u003e Code location: [send_topic_message](src/examples/send_topic_message/main.go)\n    \n4). Send a message by conditions.\nYou can send a notification message or data message to a device by conditions. Specify the conditions after obtaining the MessageRequest instance.\n\u003e Code location: [send_condition_message](src/examples/send_condition_message/main.go)\n    \n5). Send a message to a Huawei quick app.\nYou can send a message to a quick app by setting FastAppTarget.\n\u003e Code location: [send_instance_app_message](src/examples/send_instance_app_message/main.go)\n    \n6). Send a message through the APNs agent.\nYou can send a message through the APNs agent by setting Apns of the message.\n\u003e Code location: [send_apns_message](src/examples/send_apns_message/main.go)\n    \n7). Send a message through the WebPush agent.\nYou can send a message through the WebPush agent by setting WebPush of the message.\n\u003e Code location: [send_webpush_message](src/examples/send_webpush_message/main.go)\n    \n8). Send a test message.\n\u003e Code location: [send_test_message](src/examples/send_test_message/main.go)\n\n## Technical Support\nYou can visit the [Reddit community](https://www.reddit.com/r/HuaweiDevelopers/) to obtain the latest information about HMS Core and communicate with other developers.\n\nIf you have any questions about the sample code, try the following:\n- Visit [Stack Overflow](https://stackoverflow.com/questions/tagged/huawei-mobile-services?tab=Votes), submit your questions, and tag them with `huawei-mobile-services`. Huawei experts will answer your questions.\n- Visit the HMS Core section in the [HUAWEI Developer Forum](https://forums.developer.huawei.com/forumPortal/en/home?fid=0101187876626530001?ha_source=hms1) and communicate with other developers.\n\nIf you encounter any issues when using the sample code, submit your [issues](https://github.com/HMS-Core/hms-push-serverdemo-go/issues) or submit a [pull request](https://github.com/HMS-Core/hms-push-serverdemo-go/pulls).\n\n## License\nThe sample code is licensed under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhms-core%2Fhms-push-serverdemo-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhms-core%2Fhms-push-serverdemo-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhms-core%2Fhms-push-serverdemo-go/lists"}