Details steps to add DiyalogSDK Cordova plugin to ionic application
You need to configure cordova plugin in ionic application to access native functions in javascript file.
You can find below details about how you can create ionic project and create cordova plugin for Diyalog SDK.
You can skip it. If you have already an ionic/cordova project.
You can skip it. You can find DiyalogSDK Cordova plugin (DiyalogChat) in directory Plugin.
#
Configuration StepsStep 1: Download "DiyalogChat" plugin and put it on your ionic project root directory.
Step 2: Add this plugin to ionic sample application.
Once done, in config.xml in the root folder, our plugin is added.
Step 3: If you wants to remove plugin after added from project then you can use below command:
- First, you should list your plugins:
- With this result, you can simply do:
Step 4: Now for adding this installed plugin in android platform follow below command:
- If you already added android platform to ionic app, you can update platform with below command.
- After adding android platform you can see plugin file into android platform
/workspace/MyIonicApp/platforms/android/app/src/main/java/im/diyalog/ionicplugin/DiyalogChat.java
Step 5: Now call this plugin from your ionic application.
- Add button to your ionic application. I have added button into home.html file
- now open home.ts file
- Add "platform" parameter in import section:
import { NavController,Platform } from 'ionic-angular'; - Declare cordova variable:
declare var cordova: any; - Add Platform variable in constructor:
constructor(public navCtrl: NavController, public platform: Platform) - Create function for open Diyalog chat
- Add "platform" parameter in import section:
- You can see Whole file
Step 6: Now run ionic app with below command
- You can also import this project in android studio. Go to android studio and select option import project and select android project from platform directory. MyIonicApp/platforms/android.
After run application when you click on Start Messaging button you can see welcome to diyalog screen.
#
How to configure diyalog sdk into your android application#
Configuration StepsStep 1: Download Diyaload SDK (DiyalogEngine.aar) from …….
Step 2: Copy the aar file and put it under app module's libs folder. As shown in below Screen shot.
Step 3: Open Project level build.gradle file and add “flatDir{dirs 'libs'}”as shown below.
Step 4: Open module level build.grdle file.
a. set compile and target sdk version to 26 and above
b. Add the following dependencies
Step 5: Add below code at bottom of module level build.gradle files.This code require because support library version 26 and above are missing AnimatorCompatHelper class for animation, and do not change details.useVersion '25.3.0' version number.
Step 6: Open your project AndroidManifest.xml file and add below line of code inside application tag.
Note : Replace YOUR_API_KEY_HERE with your actual Map API key which you will get from your google Api console To get Map API key please check this
Link : https://developers.google.com/maps/documentation/android-api/signup
Step 7: Add below permissions into AndroidManifest.xml file.
Step 8: Create Application class and extend it with DiyalogEngineApplication. And override onConfigureDiyalogEngine() method.
Inside that method set below configure.
a. Set Server End Point:
b. Set Custom theme color:
c. Set Configurable following parameter :
- Set enable/disable audio call funcation
- Set Application name
- Invite URL
- Help line number
- Privacy policy text/URL
- Terms and condition text/URL
#
Full Code:Do not forget to mention application class in AndroidManifest.xml inside application tag using android:name property.
Step 9: Now you have done with integration steps, Add below code for open chat screen from your application. This will first check user authentication is completed or not, First time it will ask for login screen and after authentication complete it will open chat screen. Follow below steps
- a. import messenger class “import static im.diyalog.sdk.util.DiyalogEngineMessenger.messenger;”
- b. And code for start chat screen
Now run application and click on Start Messaging button it will open diyalog sdk with login screen.