0.1.0 • Published 5 years ago

cordova-plugin-hms-analytics v0.1.0

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

hms-analytics

Installing

  1. The first step would be to clone this repo in your ionic project root directory. To do that you need to run following command in terminal or in git bash.
git clone https://github.com/cloonegit/hms-analytics.git
  1. Add the plugin
ionic cordova plugins add hms-analytics
  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

Use

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

let packageId = 'xxx.xxxxxx.xxxxx';
let pageName = 'Home';
let eventName = 'Home';
let eventData = {
  'key': 'value'
};

cordova.plugins.HmsAnalytics.logEvent(
  packageId, pageName, eventName, eventData,
  (data) => { console.log(data) },
  (err) => { console.log(err) }
);