Let's Start

Follow the below steps to start the integration with Partner SDK.

  • Add mavenCentral() as part of your build.gradle file under the buildscripts.

  • allprojects { repositories { google() mavenCentral() } }
  • Add Partner SDK in your dependencies list.

  • implementation 'com.mojro.partner:core:1.3.6'

Note : Please click here to check the latest version of Partner SDK

Once the dependency got added please rebuild the project. Once this is done now you are set to use the partner SDK in your application

Environment Configuration

Environment configurations need to specify which environment SDK need to point. Please check the below code snippet

<meta-data android:name="com.mojro.partner.core.API_URL" android:value="https://testapi.mojro.com"> <meta-data android:name="com.mojro.partner.core.RESOURCE_URL" android:value="https://testresources.mojro.com">

Note above configurations are pointing to Uat. For Production it will be api.mojro.com

For More details

  • UAT : https://testapi.mojro.com

  • Prod : https://api.mojro.com

Initialize the Partner SDK

The Partner SDK is not initialized automatically any longer. Instead, you can now freely decide at which point of time the Partner SDK should be initialized. You can use the below snippet code to initialize the Partner SDK.

//Create app instance PartnerApplication partnerApplication = new PartnerApplication(getApplication(), this); partnerApplication.setActivityCallBack(new ActivityCallBack() { @Override public void onActivityCallback(int actionCode, Error error) { } });

After creating instance for partner application we need to set the activity callback as shown in the above snipped. This callback will give you action code and error based on the activity code or error you need to handle the situation. Please refer the below table for actions code and errors.

Action Code Name Actions Code
Failed -1
Success 0
On Back Pressed 1
Error Code Error Message
1200 Session is Expired. Please Login and do the required operation
1201 Not able to find the current location of the user. Please Restart the application to locate back
1203 Mata-data with API_URL or RESOURCE_URL is not configured. Please check and update in the Manifest File.
1204 We're experiencing some issues. Please get in touch with our customer care.

SDK Permissions

SDK requires below set of permissions for its functionality. Please add these permissions as part of the manifest entry and request them before taking the futher actions.

Permission Permission Entry Details in Manifest
Location <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" / > <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" / >
Storage Access <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Camera <uses-permission android:name="android.permission.CAMERA" />

Authentication

Partner SDK required authentication to be done based on the user phone number and password. This is required to perform trip releated actions. Please check the below code snippet.

//Create app instance AuthenticationBuilder authBuilder = AuthenticationBuilder.createAuthBuilder(this); authBuilder.authenticate("", "", new AuthenticationCallBack() { @Override public void onSuccess(User user) {} @Override public void onFailure(Throwable error) {} });

Mojro Trip View

Once the Authentication is done. Now its time to show the Mojro Trip View as part of the Main application. Please check the below code snippet

Add the below snippet as part of the Xml Page

<com.bluelinelabs.conductor.ChangeHandlerFrameLayout android:id="@+id/mojroTripView" android:layout_width="match_parent" android:layout_height="wrap_content"/>

Add the below snippet as part of the Java class where you have inflated the above Xml page

ViewGroup homePageTripsView = findViewById(R.id.mojroTripView); Router homePagerRouter = Conductor.attachRouter(MojroTripActivity.this, homePageTripsView, null); homePagerRouter.pushController(RouterTransaction.with(new HomePageFragment(getSupportFragmentManager(), true)));

As part of the Fragment instance you can send additional parameter called Language which helps Partner SDK to show the content based on user selected. As part of Partner SDK currently we only supporting 11 different languages.

Supported languages listed below

Language Language Code
English en
Kannada kn
Telugu te
Tamil ta
Hindi hi
Marathi mr
Bahasa in
Arabic ar
Bengali be
Filipino fil
Mandarin zh

Note : In Arabic language Partner SDK will be supported with RTL(RightToLeft)

File Provider Access

Partner SDK required file provider access if you are using POD or Digital Signature. To provide the file access please check the below code snippet.

//Your package name + provider <meta-data android:name="com.mojro.partner.core.IMAGE_PROVIDER" android:value="{packageName}.{configuredProvider}" />

Let's Start

Follow the below steps to start the integration with Partner SDK.

  • Run the below two commands in your project to add the Mojro SDK

  • cordova plugin add driver-app-sdk-plugin npm install elementtree fs

Note : Please click here to check the latest version of Partner SDK

Environment Configuration

Please note, below are the environment specific API end points which needs to be configured based on the app environment.

UAT : https://testapi.mojro.com Prod : https://api.mojro.com

Note, these need to be updated in the plugin.xml for the QA build. By default, plugin config points to prod env.

Initialize the Partner SDK

To use the Mojro SDK you need to create Mojro sdk plugin instance. Please add the below code to create Mojro SDK Instance.

//Create app instance function createMojroInstance(){ cordova.exec(success, failure, "DriverAppCordovaPlugin", "createMojroInstance",[]) function success(result){ console.log("Successfully created SDk Instance") }; function failure(result){ console.log(result); console.log("Failed to create SDK instance") }; }

Note: Call the above method after your device is ready.

SDK Permissions

SDK requires below set of permissions for its functionality. Please add these permissions as part of the manifest entry and request them before taking the futher actions.

Permission Permission Entry Details in Manifest
Location <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" / > <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" / >
Storage Access <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Camera <uses-permission android:name="android.permission.CAMERA" />

Mojro Trip View

Once the Mojro instance is done. Now is is time to show mojro trip view as part of your HTML Page. Please check the below snippet

Add the below code snippet in the html page where you wanted to show the trip View

<iframe id="mojro_ui" style="width:100%; height:110px;">;

Add the below code snippet in the Js file which is attached to the above html and pass the required attributes

const phone = encodeURIComponent('${Phone number of logged in User}'); const url = "mojro-ui-data/mojro.html?phoneNumber="+phone"; window.pluginContext = cordova;

Note : As part of the Url you need to pass the Phone number of the user to get the trip

Customizing Trip View

To update color, icons, and string resource in the trip loading iframe widget, you can alter the html and css under the www folder within mojro-ui-data plugin folder.

For example: If you want to change the title color to black, go to mojro.css file and update the color inside the title tag as shown below:

.title { color: rgba(0, 0, 0, 0.4); text-transform: none; text-align: center; font-size: 12px; }

Callback from Mojro SDK to Main App

Callback is available to refresh the data when driver comes from Mojro SDK to Main app. Please add the below details in your js file. Refresh the required data inside success callback.

cordova.exec(success, failure, "DriverAppCordovaPlugin", "lifeCycleOnResume",[]) function success(result){ console.log(result) }; function failure(result){ console.log(result) };

Resource Management

Partner SDK will provide additional feature to manage the resources like colors, string resources and icons. This feature will help you add your won color and resource to give the seem less experience to the user with the base application.

  • For String Resource add the required data as part of you config file. For Example please check the below code snippet

    <config-file parent="/*" target="strings.xml"> <string name="sample">Sample<<string> </config-file>
  • For Color and Icons Resource add the required data as part of you config file. For Example please check the below code snippet

    //Add the below hook < hook type="after_platform_add" src="www/mojro-ui-data/createResources.js" /> //Define the colors and images <color name="black" value="#000000"/>