Initial Setup

CometChat SDK v1.6 now offers support for app development in Cordova. You can use Ready UI APIs using our Cordova plugin.

Prerequisite

  • You must have installed Cordova on your system
  • Latest Android SDK
  • You will find the Cordova SDK plugin inside the “Cordova” directory of the SDK you download.

    Initial setup

  • Create cordova project as follows:
    cordova create <DIRECTORY_NAME> <APP BUNDLE ID> <APP NAME>
    e.g cordova create testapp com.testapp.app HelloWorld
  • Add Android platform in the created project as follows:
    cd testapp
    cordova platform add android
  • To install the SDK plugin in your app type the following command in your command prompt:
    cordova plugin add <PATH TO SDK_PLUGIN FOLDER>
  • Now you have to modify the AndroidManifest.xml file to add the permission which can be located under /platforms/android
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.VIBRATE" />
  • Now open build.gradle file which is present at same location and add following code
    multiDexEnabled true in section of defaultConfig {
    Add following line in just above the defaultConfig { section
    dexOptions {
            incremental true
            javaMaxHeapSize "2048M"
    }

    Add following lines in dependencies { section:

    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.pnikosis:materialish-progress:1.5'
    compile 'com.mcxiaoke.volley:library:1.0.17'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'org.jsoup:jsoup:1.8.1'
    compile 'org.apache.httpcomponents:httpcore:4.3.2'
    compile 'org.apache.httpcomponents:httpmime:4.3.3'
    compile 'com.parse.bolts:bolts-tasks:1.4.0'
    compile 'com.commit451:PhotoView:1.2.4'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.splitwise:tokenautocomplete:1.3.3'

    Add following lines after at the end of android { section

    packagingOptions {
            exclude 'META-INF/DEPENDENCIES.txt'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/dependencies.txt'
            exclude 'META-INF/LGPL2.1'
    }

    Include Readyui.js and Customui.js in your index.html file to access Ready UI functionality in your Cordova app

  • Not finding what you need?

    The CometChat team is here to help!