{"id":19672732,"url":"https://github.com/halilozel1903/huaweipushkitapp","last_synced_at":"2025-04-29T01:30:49.573Z","repository":{"id":43229853,"uuid":"315950168","full_name":"halilozel1903/HuaweiPushKitApp","owner":"halilozel1903","description":"An Android application related to Huawei Push Kit 🚨 📩  📨","archived":false,"fork":false,"pushed_at":"2024-04-14T18:24:14.000Z","size":7196,"stargazers_count":14,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-02T02:10:06.417Z","etag":null,"topics":["android-push-message","android-push-notification","firebase-cloud-messaging","hms","hms-push","hms-pushkit","hms-sample","huawei","huawei-devices","huawei-mobile-services","huawei-push","push","push-kit","push-notification","push-notification-android","push-notification-client","push-notification-server","push-notifications","send-message"],"latest_commit_sha":null,"homepage":"https://halilozel1903.medium.com","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halilozel1903.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-11-25T13:38:05.000Z","updated_at":"2023-08-03T13:33:47.000Z","dependencies_parsed_at":"2024-04-19T12:00:40.401Z","dependency_job_id":null,"html_url":"https://github.com/halilozel1903/HuaweiPushKitApp","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/halilozel1903%2FHuaweiPushKitApp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FHuaweiPushKitApp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FHuaweiPushKitApp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FHuaweiPushKitApp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halilozel1903","download_url":"https://codeload.github.com/halilozel1903/HuaweiPushKitApp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251415618,"owners_count":21585865,"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":["android-push-message","android-push-notification","firebase-cloud-messaging","hms","hms-push","hms-pushkit","hms-sample","huawei","huawei-devices","huawei-mobile-services","huawei-push","push","push-kit","push-notification","push-notification-android","push-notification-client","push-notification-server","push-notifications","send-message"],"created_at":"2024-11-11T17:13:10.228Z","updated_at":"2025-04-29T01:30:45.736Z","avatar_url":"https://github.com/halilozel1903.png","language":"Kotlin","funding_links":["https://www.buymeacoffee.com/halilozel1903"],"categories":[],"sub_categories":[],"readme":"## Huawei Push Kit 🛠\n\nHello everyone, Today we will learn Huawei Push Kit.\n\n**Note** : Used within the Huawei Map Kit application. Similar steps exist.\n\nhttps://github.com/halilozel1903/HuaweiMapKitApp\n\n## What is Huawei Push Kit ⁉️\n\n![Huawei](https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huawei-push-kit-doc.jpeg)\n\n**HUAWEI Push Kit** is a messaging service provided for you. It establishes a messaging channel from the cloud to devices. By integrating Push Kit, you can send messages to your apps on users' devices in real time. This helps you maintain closer ties with users and increases user awareness of and engagement with your apps. The following figure shows the process of sending messages from the cloud to devices.\n\nCurrently, Push Kit has been supported in mobile phones, tablets, HUAWEI Vision, HUAWEI Watch, and Volvo and Dongfeng Sokon head units.\n\nFor more : https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-sdk-introduction-0000001050158633\n\n## How to use Huawei Push Kit 📌\n\nYou can follow the steps in this blog post.\n\nThe steps we need to integrate for **Push Kit** are as follows.\n\n- We activate Push Kit from the Manage API section\n\n![PushKitIntegration](https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huawei-push-kit.png)\n\n- We are making Push Kit integrations.\n\n![PushKitEnable](https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huawei-push-kit-enable.png)\n\n- We choose Germany from the data storage location section.\n\n![PushKitLocation](https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huawei-push-kit-location.png)\n\n- We fill in the fields below for the notification example.\n\n![PushKitLocation](https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huawei-push-kit-sample.png)\n\n- When we click the test effect button, it will ask us for tokens.\n\nIn this step, we will be able to learn the token value we need when we integrate the Push Kit into the application.\n\n- Push Kit added in **build.gradle(:app)**\n\n ```kotlin\n implementation 'com.huawei.hms:push:6.1.0.300'\n ```\n\n\n- We create a function in Main Activity. We define an instance to get the token value.\n\n```kotlin\n       private fun getToken() {\n           object : Thread() {\n               override fun run() {\n                   try {\n                       val appId = AGConnectOptionsBuilder().build(this@MainActivity)\n                           .getString(\"client/app_id\")\n                       val token = HmsInstanceId.getInstance(this@MainActivity)\n                           .getToken(appId, \"HCM\")\n                       Log.i(\"PUSH\", \"getToken() token: $token\")\n                   } catch (e: ApiException) {\n                       Log.e(\"PUSH\", \"getToken() failure: ${e.message}\")\n                   }\n               }\n           }.start()\n       }\n```\n\nRun the application. The token value is displayed in the log section.\n\n![HuaweiPushKToken](https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huaweiPushKitToken.png)\n\n\nPut this token value in the field in the Push Kit test.\n\n![HuaweiPushTest](https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huawei-push-kit-test.png)\n\n\nIt will test the application with Cloud Debugging.You can run the application by following the below document.\n\nhttps://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-clouddebug-realtimedebug\n\n\nWe have done all the necessary actions. Congratulations 🥳 You have developed the first Huawei Push Kit application.\n\n\u003cimg src=\"https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huawei-push-kit-screen.png\" width=\"300\" /\u003e\n\n\n## Testing with Postman 📨\n\nYou can test the application with Postman by following the steps below.\n\n- Download the json file located in the url below.\n\nhttps://gist.github.com/halilozel1903/a9bc9c09bd00ac490fbb26d4ffeefa38\n\n- Open Postman. Import the file. (Postman -\u003e file -\u003e import)\nAfter you import, we can send 3 requests\n\n\u003cimg src=\"https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huaweiPushKitPostman.png\" width=\"300\" /\u003e\n\n- Replace the **app_id** and **app_secret** values in the body with the App ID and App secret values on the application home page of the Huawei Console. Replace the fields in the image below with the values in your own project.\n\n![huaweiPushGallery](https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huaweiPushGallery.png)\n\n\n- Change the **app_id** value in the link in the Send notification and Send data message files with the App ID on the application page in the console.\n\n- Open the Send notification and Send data message files and replace the **push_token** part in the Body with the token we get from the application logs.\n\n![PushKitToken](https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huaweiPushToken.png)\n\n- Open the Get access token file and click the Send button to **get access token**. The access token is valid for 3600 seconds and you need to renew it later.\n\n![huaweiPushAccessToken](https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huaweiPushAccessToken.png)\n\n- Open the Send notification and Send data message file and replace the access_token part in Authorization with the access token we got in before step. Don't forget to delete this characters \\  in the access token.\n\n![huaweiPushSend](https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huaweiPushSend.png)\n\nWhen we follow the steps above and make a request, we will have successfully seen our notifications on the screen.\n\n\u003cimg src=\"https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huaweiPushScreen2.png\" width=\"300\" /\u003e \u003cimg src=\"https://github.com/halilozel1903/HuaweiPushKitApp/blob/master/photos/huaweiPushScreen1.png\" width=\"300\" /\u003e\n\n\n## Recourses 📚\n\n1. https://developer.huawei.com/consumer/en/codelab/HMSPushKit/\n\n2. https://developer.huawei.com/consumer/en/hms/huawei-pushkit/\n\n3. https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/push-console\n\n## Donation 💸\n\nIf this project help 💁 you to develop, you can give me a cup of coffee. ☕\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/halilozel1903)\n\n## License ℹ️\n```\nMIT License\n\nCopyright (c) 2022 Halil OZEL\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalilozel1903%2Fhuaweipushkitapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalilozel1903%2Fhuaweipushkitapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalilozel1903%2Fhuaweipushkitapp/lists"}