项目作者: plumb5

项目描述 :
App analytics SDK for IONIC / CORDOVA based applications
高级语言: Java
项目地址: git://github.com/plumb5/IONIC-SDK.git
创建时间: 2020-09-04T11:02:07Z
项目社区:https://github.com/plumb5/IONIC-SDK

开源协议:

下载


IONIC-SDK

App analytics SDK for IONIC based applications

Plumb5 IONIC SDK

Software Requirements

  • Android:
    • Minimum Version :16
    • Maximum Version :30
    • Gradle: Greater than or equal to 3.5
    • Google-Service: 4.2.0
  • Ios
  • Cordova
    • Requirement : greater than 3
  • Ionic
    • Requirement : greater than or equal to 4

Prerequisites

  • Variable

    • PLUMB5_ACCOUNT_ID
    • PLUMB5_API_KEY
    • PLUMB5_BASE_URL
  • File

    • Google-services.json
    • ic_p5_logo.png(16px X 16px or 14px X 14px)
  • Permissions(optional)

    • Location
    • Phone State
    • Phone Number
    • Wake Lock

Pre installation

FCM config

Add your google-services.json to the root of your cordova project before you add the plugin.

Add

  • Edit config.xml :
    • Under platform “Android”
      • add this line
        1. <resource-file src="google-services.json" target="app/google-services.json" ></resource-file>
  1. * Under platform Ios

Starting the installation

From root of application

Add plugin

  • Using Cordova:

    1. cordova plugin add PATH/Git URL --variable

    PLUMB5_ACCOUNT_ID=”YOUR PLUMB5 ID“ —variable
    PLUMB5_API_KEY=”YOUR PLUMB5 KEY“ —variable
    PLUMB5_BASE_URL=”YOUR PLUMB5 URL

  • Using Ionic:
    1. `ionic` `cordova plugin add` **PATH/Git URL --variable
    PLUMB5_ACCOUNT_ID=”YOUR PLUMB5 ID“ —variable
    PLUMB5_API_KEY=”YOUR PLUMB5 KEY“ —variable
    PLUMB5_BASE_URL=”YOUR PLUMB5 URL

Remove plugin

  • Using Cordova:

    1. cordova plugin rm cordova-plugin-plumb5
  1. * Please ignore the error after removing the plugin
  • Using Ionic:

    1. ionic cordova plugin rm cordova-plugin-plumb5
  1. * Please ignore the error after removing the plugin

For Ionic

Add app.component.ts

  1. import { Component } from '@angular/core';
  2. import { Platform } from '@ionic/angular';
  3. import { Router, NavigationStart, ActivatedRoute} from '@angular/router';
  4. declare var cordova: any;
  5. var p5 = cordova.plugins.Plumb5.init();
  6. export class AppComponent {
  7. constructor(
  8. private platform: Platform,
  9. public router: Router,
  10. private pageParameter:ActivatedRoute
  11. ) {
  12. this.initializeApp();
  13. p5.setup();
  14. //Plumb5 lifecycle and in-app
  15. this.router.events.forEach((event) => {
  16. if (event instanceof NavigationStart) {
  17. p5.tracking([{ ScreenName: event.url, PageParameter: "" }]); p5.pushResponsePost([{ ScreenName: event.url, PageParameter: "" }]);
  18. }
  19. });
  20. }
  21. initializeApp() {
  22. this.platform.ready().then(() => {
  23. //page navigation listener
  24. document.addEventListener('onPushNotification', (e: any) => {
  25. let routeUrl = e.routeUrl
  26. this.router.navigate([routeUrl]);
  27. });
  28. });
  29. }

Example

  • User details

    1. var userDetailsJson =[
    2. {
    3. "Name": "demo",
    4. "EmailId": "demo@demo.com",
    5. "PhoneNumber": "987654321",
    6. "LeadType": 1,
    7. "Gender": "Male",
    8. "Age": "2020-01-27T06:12:01.051Z",
    9. "AgeRange": "10-89",
    10. "MaritalStatus": "Married",
    11. "Education": "MCA",
    12. "Occupation": "SE",
    13. "Interests": "Eating",
    14. "Location": "Bangalore"
    15. //Add extra parameters
    16. "key":"value"
    17. }
    18. ]
    19. p5.setUserDetails(userDetailsJson);
  • Event

    • Html:
    1. <ion-button color="primary" (click)="btn1()">Event Post</ion-button>
  1. * **Component.ts**
  2. ```smalltalk
  3. btn1(){
  4. let eventDetailsJson =[
  5. {
  6. "Type": "Button",
  7. "Name": "Event Post",
  8. "Value": 1
  9. }
  10. ]
  11. p5.eventPost(eventDetailsJson);
  12. }
  13. ```