logo indigitall logo indigitall
/indigitall setup /App push quickstart /Cordova

EN  | 

ES



Cordova SDK

indigitall Cordova SDK Setup Guide.



Required for setup



Installation

indigitall SDK is available through NPM.
Import the SDK to your project with the following steps:

  1. Open a console go to your project path

    $ cd /PATH/TO/YOUR/PROJECT


  2. Add indigitall SDK to your project
    $ cordova plugin add indigitall-cordova-plugin




Android requisites

You need obtain the 'google-services.json' file from Firebase Console.


Once you have it, import it to the root file of your project.
After that, include this code into your config.xml file in the android section.

<platform name="android">
    <resource-file src="google-services.json" target="/google-services.json" />
    ...
</platform>


Add HMS Services

Adding HMS Services


  1. To start you need a file called agconnect-services.json . You can export this file from the Huawei developer console .

  2. Move it to the root of your project folder. You should have something like this:


File structure of the Cordova project

  1. Add the following code in the file config.xml inside the android section.


<platform name = "android">
    <resource-file src = "agconnect-services.json" target = "/agconnect-services.json" />
    ...
</platform>


  1. Once the android project is created, it must be added in the manifest of the application, which is located in the following path:


Estructura de ficheros del proyecto Cordova


  1. Add the following lines:


<service android:exported="false" android:name="com.indigitall.android.services.HMSMessagingService">
    <intent-filter>
        <action android:name="com.huawei.push.action.MESSAGING_EVENT" />
    </intent-filter>
</service>


  1. Also edit the build.gradle, which is located at the following path:


Estructura de ficheros del proyecto Cordova


  1. Add the following lines:


apply plugin: 'com.huawei.agconnect'

buildscript {
    repositories {
        mavenCentral()
        google()
        jcenter()
        maven {url 'https://developer.huawei.com/repo/'}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath 'com.huawei.agconnect:agcp:1.2.1.301'  
    }
}

allprojects {
    repositories {
        mavenCentral()
        jcenter()
        maven {url 'https://developer.huawei.com/repo/'}
    }
}
apply plugin: 'com.google.gms.google-services'

...
dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    ...
    implementation "com.google.firebase:firebase-core:17.2.2"
    implementation "com.google.firebase:firebase-messaging:20.1.0"

    implementation "com.huawei.hms:location:5.0.0.301" // GET LOCATION
    // SUB-PROJECT DEPENDENCIES END
}


iOS requisites

In iOS you need add the Notification Service Extension to your project with Xcode. You can learn how to do this in the Notification Service Extension in our iOS documentation.


Initialization


window.plugins.indigitall.init({ appKey: "<YOUR_APP_KEY>", senderId: "<YOUR_SENDER_ID>" });




Test the Integration

¿?



Video explanation