Cordova Chat code sample - How To guide
Here we explain how to run origin Chat code sample for browser on Cordova/PhoneGap environment
Complete Chat API integration guide for Web/Javascript and Hybrid apps is here
Integration details
- Make sure you have the latest Cordova installed:
The output will be something like this:
If Cordova is not installed - run the following command:
- Create Cordova app:
You can use the Create your first Cordova app guide to get more info how to create your 1st Cordova app.
- Change directory to newly created Cordova app:
- Add platforms:
- Install cordova-plugin-device plugin:
- Install cordova-custom-config plugin
Then add the following lines into config.xml (for iOS 10+, to support files attachments in sample):
And the following for Android:
Also, don’t forget to put the xmlns:android="http://schemas.android.com/apk/res/android"
attribute in the root widget
element.
More info on Android permissions.
Then add a code to ask Android users for permissions. You can copy the needed code from the file: https://github.com/ConnectyCube/connectycube-cordova-samples-materials/blob/master/sample-chat-cordova/cordova-permissions.js
-
Install iOS Deployment Tools if you want to launch iOS app on iOS device.
-
Copy content from sample-chat-web folder to www folder of your Cordova app. The following command can be used for it:
- Connect
cordova.js
at yourindex.html
file:
- Finally, use the following commands to run the sample:
The complete
config.xml
,package.json
andcordova-permissions.js
are available at GitHub repository
Debugging
The following tools will help you debug your Cordova application:
Can’t build yourself?
Got troubles with building Cordova code sample? Just create an issue at Issues page - we will create the sample for you. For FREE!