{"id":26188210,"url":"https://github.com/waitaction/cordova-plugin-huawei-push","last_synced_at":"2025-07-22T13:05:15.152Z","repository":{"id":57214994,"uuid":"292767532","full_name":"waitaction/cordova-plugin-huawei-push","owner":"waitaction","description":"华为推送Cordova插件","archived":false,"fork":false,"pushed_at":"2020-09-04T08:55:38.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-04T10:43:33.083Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","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/waitaction.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}},"created_at":"2020-09-04T06:25:39.000Z","updated_at":"2021-02-22T08:30:39.000Z","dependencies_parsed_at":"2022-08-24T21:00:41.894Z","dependency_job_id":null,"html_url":"https://github.com/waitaction/cordova-plugin-huawei-push","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/waitaction/cordova-plugin-huawei-push","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waitaction%2Fcordova-plugin-huawei-push","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waitaction%2Fcordova-plugin-huawei-push/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waitaction%2Fcordova-plugin-huawei-push/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waitaction%2Fcordova-plugin-huawei-push/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/waitaction","download_url":"https://codeload.github.com/waitaction/cordova-plugin-huawei-push/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waitaction%2Fcordova-plugin-huawei-push/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266499045,"owners_count":23938779,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-03-11T23:57:34.198Z","updated_at":"2025-07-22T13:05:15.130Z","avatar_url":"https://github.com/waitaction.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":" # 华为推送\n\n华为手机推送\n\n安装`cordova-plugin-huawei-push`\n\n ```\n cordova plugin add cordova-plugin-huawei-push\n ```\n\n## 华为推送配置\n\n在项目根目录建个文件夹 `config-push` ，将 `agconnect-services.json` 拷贝到 `config-push` 目录。\n\n\u003e `agconnect-services.json` 文件，请从华为开发者官网配置推送后下载到本地。\n\u003e [华为开发者官网](https://developer.huawei.com/consumer/cn/)\n\n调试推送需要使用签名后的apk，因此建议在 `cordova` 根目录建 `build.json` 文件，把签名信息配置一下\n\n``` json\n{\n    \"android\": {\n        \"debug\": {\n            \"keystore\": \"./keys/testpush.keystore\",\n            \"alias\": \"testpush.keystore\",\n            \"storePassword\": \"123456\",\n            \"password\": \"123456\"\n        },\n        \"release\": {\n            \"keystore\": \"./keys/testpush.keystore\",\n            \"alias\": \"testpush.keystore\",\n            \"storePassword\": \"123456\",\n            \"password\": \"123456\"\n        }\n    }\n}\n```\n\n\u003e `build.json` 的上述配置需要改成你自已的配置信息\n\n如需调试，需要在真实的设备，使用以下命令调试\n\n``` shell\ncordova run android --device --buildConfig\n```\n\n## 使用\n\n使用前需注册，以获取 `token` ，你可以将 `token` 与你的app用户信息关联后上传到服务器\n\n``` js\n// 注册推送\nhuaweiPush.register(function(token) {\n    console.log(token);\n}, function(err) {\n    console.log(err);\n}, []);\n\n// 接收token\nhuaweiPush.onNewToken(function(token) {\n    console.log(token); // 会多次接收到token\n});\n```\n\n注册完成后，需要监听 `messageReceived` 事件\n\n``` js\ndocument.addEventListener(\"messageReceived\", function(result) {\n    console.log(result);\n}, false);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaitaction%2Fcordova-plugin-huawei-push","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwaitaction%2Fcordova-plugin-huawei-push","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaitaction%2Fcordova-plugin-huawei-push/lists"}