Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-huawei-push

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-huawei-push

Cordova Push Plugin

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

华为推送

华为手机推送

安装cordova-plugin-huawei-push

cordova plugin add cordova-plugin-huawei-push

华为推送配置

在项目根目录建个文件夹 config-push ,将 agconnect-services.json 拷贝到 config-push 目录。

agconnect-services.json 文件,请从华为开发者官网配置推送后下载到本地。 华为开发者官网

调试推送需要使用签名后的apk,因此建议在 cordova 根目录建 build.json 文件,把签名信息配置一下

{
    "android": {
        "debug": {
            "keystore": "./keys/testpush.keystore",
            "alias": "testpush.keystore",
            "storePassword": "123456",
            "password": "123456"
        },
        "release": {
            "keystore": "./keys/testpush.keystore",
            "alias": "testpush.keystore",
            "storePassword": "123456",
            "password": "123456"
        }
    }
}

build.json 的上述配置需要改成你自已的配置信息

如需调试,需要在真实的设备,使用以下命令调试

cordova run android --device --buildConfig

使用

使用前需注册,以获取 token ,你可以将 token 与你的app用户信息关联后上传到服务器

// 注册推送
huaweiPush.register(function(token) {
    console.log(token);
}, function(err) {
    console.log(err);
}, []);

// 接收token
huaweiPush.onNewToken(function(token) {
    console.log(token); // 会多次接收到token
});

注册完成后,需要监听 messageReceived 事件

document.addEventListener("messageReceived", function(result) {
    console.log(result);
}, false);

Keywords

FAQs

Package last updated on 04 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc