0.0.1 • Published 6 years ago

cordova-plugin-hms-push v0.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
6 years ago

hms-push

Installing

  1. The first step would be to clone this repo in root directory of ionic project. To do that you need to run following command in terminal or in git bash.
git clone https://github.com/cloonegit/hms-push.git
  1. Add the plugin
ionic cordova plugins add hms-push
  1. In your ionic project build.gradle (inside platform/android), add
buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'http://developer.huawei.com/repo/' }
    }

    dependencies {
        classpath 'com.huawei.agconnect:agcp:1.0.0.300'
    }
}
...
  1. Add agconnect-services.json file inside platform/android/app

  2. This plugin requires apk signing. So, create your keystore. You may refer to this website for more detail explanation: https://developer.nevercode.io/docs/signing-android-binaries-in-cordova

keytool -genkey -v -keystore release.keystore -alias app_release -keyalg RSA -keysize 2048 -validity 10000
  1. Create build.json file and put it in the root directory of ionic project. Copy paste following code and rename the value based on your generated keystore file.
{
    "android": {
        "debug": {
            "keystore": "yourkeystore.keystore",
            "storePassword": "yourpassword",
            "alias": "youralias",
            "password" : "yourpassword",
            "keystoreType": ""
        },
        "release": {
            "keystore": "yourkeystore.keystore",
            "storePassword": "yourpassword",
            "alias": "youralias",
            "password" : "yourpassword",
            "keystoreType": ""
        }
    }
}
  1. When you build your apk, you need to build release version of the apk
ionic cordova build --release android

Use

  1. To apply the plugin, add following code
declare var cordova: any;

let appId = "yourAppId"

cordova.plugins.HmsAnalytics.getToken(appId,
  (data) => { console.log(data) },
  (err) => { console.log(err) }
);
0.0.1

6 years ago

0.1.0

6 years ago