0.0.1 • Published 6 years ago
cordova-plugin-hms-push v0.0.1
hms-push
Installing
- 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
- Add the plugin
ionic cordova plugins add hms-push
- 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'
}
}
...
Add agconnect-services.json file inside platform/android/app
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
- 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": ""
}
}
}
- When you build your apk, you need to build release version of the apk
ionic cordova build --release android
Use
- 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) }
);