CometChat SDK v1.6 now offers support for app development in Cordova. You can use Ready UI APIs using our Cordova plugin.
Prerequisite
You will find the Cordova SDK plugin inside the “cordova” directory of the SDK you download.
cordova create <DIRECTORY_NAME> <APP BUNDLE ID> <APP NAME>
e.g cordova create testapp com.testapp.app HelloWorld
cd testapp
cordova platform add android
cordova plugin add <PATH TO SDK_PLUGIN FOLDER>
<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" />
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 in your index.html file to access Ready UI functionality in your Cordova app
Now your android app is ready to build.
Ready UI offers you the following apis:
Set API KEY
Pass the url where you have installed CometChat by using the setApiKey() function.
e.g
Readyui.setApiKey("API-Key");
Login to CometChat
Login to CometChat by passing the username and password to the function login().
e.g
Readyui.login("John","passw0rd");
Launch Chat in your app
Launch Chat app inside your app by using the launchCometChat() function.
e.g
Readyui.launchCometChat();
Launch Chat window
If you wish to load the chat window of any specific user instead of opening the entire chat app you can use the chatWithMe() function for this purpose. Pass the user id of the user with whom you wish to chat.
e.g
Readyui.chatWithMe("2")
Not finding what you need?
The CometChat team is here to help!