Description.
This package is allow your flutter client application to integrate the Hailify job delivery feature inside client application. By Hailify
Supported Platforms
- Android
Deployed on Android 6(marshmalllow) or higher
- iOS
Deployed on iOS 13 or higher
Step 1: Add Hailify package to your app
- To use this plugin, add
hailify: ^0.0.1
as adependency
in yourpubspec.yaml
Android Installation
Add the following to your android/build.gradle
:
under section allprojects/repositories
maven {
url 'https://hailifyfleet.jfrog.io/artifactory/hailifyfleet'
//Hailify will provide you username and password for downloading sdk
credentials{
username "USER_NAME"
password "PASSWORD"
}
}
iOS Installation
- On iOS, lines below have to be added inside
ios/Podfile
:
use_frameworks!
#*~~~~~ set 'BUILD_LIBRARY_FOR_DISTRIBUTION' = 'YES' to all of your pods target ~~~~~*#
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
- Run
pod install
to install in terminal from your iOS project folder.
Notes:- You need to add below permissions in ios/Runner/Info.plist
. Ignore if you have added already. You can set description as per usage.
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app collects your location data to improve pickups & drop-offs delivery packages and to enhance safety. You can turn off location data anytime in your phone’s device.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app collects your location data to improve pickups & drop-offs delivery packages and to enhance safety. You can turn off location data anytime in your phone’s device.</string>
<key>NSCameraUsageDescription</key>
<string>This app will use your camera to take pictures to confirm deliver packages.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app will use your library to select delivery packages.</string>
- In order to enable geolocation in the background, you need to include location as a background mode in the
Capabilities
tab in Xcode.
Step 2: Import Plugin
import 'package:hailify/hailify.dart';
Import package into your main.dart file or where you want to access Hailify package.
Example:-
import 'package:hailify/hailify.dart';
Step 3: Initialize SDK
Hailify.initilize("<fleet-name>","<fleet-token>");
- initialize a Hailify SDK shared instance with key/token
Note:- Hailify will provide sandbox/production SDK key/token.
-
fleetName: Name of your company
-
fleetToken: Token which provided by hailify to you.
Example:-
Hailify.initilize("Name", "myToken1234");
Step 4: Set Driver ID
Hailify.setDriverId("<driver-id>");
- driverId: ID of your driver who is registered with your organization.
Example:-
Hailify.setDriverId("a123");
Step 5: Open Order View
Hailify.showOrderPopup();
- App should call this method once you got success response from Assign Driver end-point(AssignBooking)
Sandbox Environment
Hailify.enableSandbox(true/false);
- By default it is
false
- Enable sandbox environment in order to test orders.
Example:-
Hailify.enableSandbox(true);
Location Engine
Hailify.useSDKLocationEngine(true/false);
- By default it is
false
. - Allow Hailify SDK to use SDK Location engine.
Example:-
Hailify.useSDKLocationEngine(true);
- Or provide your location from your app to Hailify SDK with calling above method.
Hailify.useSDKLocationEngine(false);
Hailify.setLocation(latitude, longitude, accuracy);
Example:-
Hailify.useSDKLocationEngine(false);
Hailify.setLocation(40.0, -74.0, 5);
Initialize Delivery View
Hailify.initializeDeliveryView(callback);
- For adding the Delivery View inside your cordova application you have to call this method and after successful initialize of Delivery view, you will get a success callback. then you can set other listeners which is related to Delivery view and can receive order updates after initialize from SDK.
Example:-
Hailify.initializeDeliveryView(() => {
//do necessory need
});
Navigation Listener (Optional)
Hailify.setNavigationListener(callback);
- Customize navigation option for the current order. To fetch current order latitude & longitude, Add following listener method. If this listener will not defined then Hailify SDK opens route from current location to Order location in Apple Maps or Google Maps based on what is installed in the device.
- This is optional method.
Example:-
Note: You Have to set this listener after the successful initilization of the delivery view.
Hailify.setNavigationListener((latitude, longitude) => {
log("Location : " + latitude.toString() + ", " + longitude.toString());
});
Order Status Listener (Optional)
Hailify.setOrderStatusListener(callback);
- Define following listener method If you want to get updated status of current order. This listener callback will call when the current order status will change. Possible values: Check Delivery Statuses
- This is optional method.
Example:-
Note: You Have to set this listener after the successful initilization of the delivery view.
Hailify.setOrderStatusListener((orderStatus, orderId) => {
log("orderStatus : " + orderStatus + ", orderId: " + orderId);
});
Order Complete Listener (Optional)
Hailify.setCompleteListener(callback);
- Following listener method will call just after you will complete the current booking.
- This is optional method.
Example:-
Note: You Have to set this listener after the successful initilization of the delivery view.
Hailify.setCompleteListener(() => {
log("Post Order Completion handler will be here");
});
Call Listener (Optional)
Hailify.setCallListener(callback)
- Customize call option for the current order location(either pick-up or drop-off). Add following listener method in order to get phone number of pick-up or drop-off location. If this method will not defined then Hailify SDK call to the current order’s location from the device.
- This is optional method.
Example:-
Note: You Have to set this listener after the successful initilization of the delivery view.
Hailify.setCallListener((number) => {
log("phone number : " + number);
});
Get order Status (Optional)
Hailify.getCurrentOrderStatus.then(<callback>)
- Get order current status at any time. Possible values: Check Delivery Statuses
Example:-
Hailify.getCurrentOrderStatus.then((status) => {
log("Currenet Order Status: " + status.toString())
});
Set Height of Delivery view (Optional)
Hailify.setMaxHeightPercentage(<double/int value in percentage>);
It will set the height of the delivery view as per your requirement.
Example:-
Hailify.setMaxHeightPercentage(80);
Delivery Statuses
Status | Description |
---|---|
booked | delivery is successfully created and courier en-route soon |
to_pickup | courier actively on his way to pickup location |
at_pickup | courier at pickup location |
to_delivery | courier picked up the order and actively on his way to delivery location |
at_delivery | courier at delivery location |
to_return | courier return in transit to pickup location. (Only Return flow) |
returned | delivery returned |
delivered | delivery completed |
cancelled | delivery cancelled |
failed | the delivery was not complete because of a merchant or customer facing issue |
##Quick Example
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
try {
Hailify.initilize("<fleet-name>",
"<fleet-token>");
Hailify.enableSandbox(true);
Hailify.useSDKLocationEngine(true);
Hailify.setDriverId("<driver-id>");
//Hailify.setLocation(latitude, longitude, accuracy);
Hailify.initializeDeliveryView(() => {
Hailify.setMaxHeightPercentage(90)
});
Hailify.setCallListener(
(number) => {
});
Hailify.setOrderStatusListener((orderStatus, orderId) => {});
Hailify.setNavigationListener((latitude, longitude) => {
log("setNavigationListener : " +
latitude.toString() +
" " +
longitude.toString())
});
Hailify.setCompleteListener(() => {log("completion of order")});
// Call showOrderPopup() only after assign the job order to the user.
Hailify.showOrderPopup();
// getCUrrent order status will give you the current order status.
Hailify.getCurrentOrderStatus.then((status) => {
log("Currenet Order Status: " + status.toString())
});
} on PlatformException {}
}
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
child: TextButton(child: Text('Hello World'), onPressed: null),
),
),
);
}
}