Latest 3.0.0
Homepage https://github.com/apiosys/SfaraSDK
License Commericial
Platforms ios 8.3, requires ARC
Dependencies Godzippa
Frameworks UIKit, Foundation, SystemConfiguration, MobileCoreServices, CoreLocation
Authors

SfaraSDK for iOS

The SfaraSDK for iOS enables Sfara customers track driver behavior and receive real-time event notifications for enrolled drivers. In addition to real-time notifications, these behaviors and events are uploaded to Sfara’s hosted cloud, allowing Sfara’s customers later access to the behaviors and overall driving scores of their company’s drivers.

SfaraSDK employs Sfara’s patented real-time crash detection to notify the host application if SfaraSDK detects a vehicle crash using the phone’s sensors.

Requirements and Supported Devices for iOS Version

  • iOS 8.3 and higher
  • iPhone 5S, SE, 6, 6 Plus, 6S, 6S Plus, 7, and 7 Plus
  • Host application must enable the location UIBackgroundMode and location always usage
  • The host application must also obtain the Always Usage and Motion Usage permissions from the user.

Getting Started

  • Receive a SfaraSDK Developer Key
  • Install the SfaraSDK (CocoaPods is recommended)
  • Change project settings to enable SDK
  • Using the SDK in App.
  • Check out the full SDK documentation on cocoadocs.
  • Check out the wiki for details on specific topics.

Changes and Release Notes:

  • DriversitiSDK is now SfaraSDK

1. Receive a SfaraSDK Developer Key

Before SfaraSDK will operate, your organization will need to acquire an SfaraSDK Developer Key.
Your organization only needs one shared SDK key, which can be used by multiple developers within your organization and for both the iOS and Android platforms.
Email [email protected] for more information on how your company can obtain a developer key.

Before SfaraSDK will operate, your organization will need to acquire an SfaraSDK Developer Key, which may be requested by contacting us.
Your organization only needs one shared SDK key, which can be used by multiple developers within your organization and for both the iOS and Android platforms.

2a. Installing the SfaraSDK (CocoaPods)

Sfara recommends and supports the use of CocoaPods to manage downloading and linking the SfaraSDK into your app project. To integrate, simply specify it in your Podfile. For example

  pod 'SfaraSDK', '~> 3.0.0'

2b. Installing the SfaraSDK manually

While CocoaPods is recommended, developers using other project dependency managers can incorporate the SfaraSDK manually. Developers can find the following required files within this repository.

  • A static library, libSfaraSDK.a, located in the repository root.
  • Public header files located in include/SfaraSDK/.
  • A required resource bundle named Sfara.bundle located in the repository root. This bundle must be include as-is into the host applications main bundle.

Additionally, a developer incorporating manually, must also incorporate SfaraSDK’s required dependencies. These dependencies are listed in the SfaraSDK.podspec file located in the repository root.

3. Required App Project Settings

  • Enable BitCode needs to be set to NO at the application project level.
  • Background Modes under Capabilities must be turned on, and Location Updates must be enabled.
  • NSLocationAlwaysUsageDescription in your Info.plist must be specified. The string specified will be prompted to the user once the SfaraSDK starts up, if the app had not already received prior user permission to always run in the background.
  • NSMotionUsageDescription in your Info.plist must also be specified. The string specified will be prompted to the user once the SfaraSDK starts up unless the permission was already obtained at a previous point in time.
  • It is advised that the developer obtain the appropriate ‘location’ and ‘motion’ permissions prior to initializing and starting the SDK.

4. Using the SDK in App.

a. Initialize the SDK

When using the SDK, a developer should first set the organization’s key on the shared SfaraSDK object. An example application:didFinishLaunchingWithOptions: for the host application is provided below.

#import <SfaraSDK/SfaraSDK.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    /* Set the APIKey for the SDK and start the SDK

     NOTE:
     Starting the SDK before prompting for 'Privacy - Location Always Usage Description' will lead to the SDK to prompt instead.
     It is advised that the App obtain this permission before had in some other phase before.

     */
    [Sfara setAPIKey:@"developerKey"];
    [Sfara startDataCollectionWithHandler:^(NSError * _Nullable error) {
        //
    }];

    return YES;
}

replacing developerKey with your actual key.

Additionally, to gracefully handle application shut down, the developer should include the following in their ”applicationWillTerminate”

- (void)applicationWillTerminate:(UIApplication *)application {
    // Call this here to gracefully terminate the SDK and wrap up the current trip to avoid any invalid trips.
    [Sfara shutdown];
}

b. Register User

Before the SDK can begin reporting detections, a User needs to be registered with the user manager class SFUserManager. An example is provided below.

[[SFUserManager sharedInstance] userRegisterWithEmailAddress:email
                                                    password:password
                                                   firstName:@""
                                                  middleName:@""
                                                    lastName:@""
                                               streetAddress:@""
                                                        city:@""
                                                       state:@""
                                                     country:@""
                                                     zipcode:@""
                                                 phoneNumber:@""
                                                    username:@""
                                                   companyId:company
                                             completionBlock:^(NSError *error) { }];

The company a user is registering with will need to be set to the Company name specified to you by [email protected].

c. Recieving detections

To receive detection, the host application will need to register an instance conforming to the SFDetectionsDelegate protocol using the detectionsDelegate property on SFSfaraSDK class.

#import <SFSfaraSDK.h>
@interface ViewController () <SFDetectionsDelegate>
...

// Set the 'sensorDelegate' property of the DriversitiSDK to self and conform to the delegate protocol recieve desired events.
Sfara.detectionsDelegate = self;

All detections are reported through the SFDetectionsDelegate

- (void)rapidAccelerationDetectedAtLocation:(nullable CLLocation *)location {
        NSLog(@"@"Last Detection: Rapid Accel!");
}

Contact / Support

Visit us at www.sfara.com or drop an email to [email protected]

Latest podspec

{
    "name": "SfaraSDK",
    "version": "3.0.0",
    "summary": "Driving safety for the mobile generation. Real-time notifications of unsafe driving behaviors.",
    "description": "Transform smartphones from driver's worst enemy to their best friendn- SDK leverages algorithms that use smartphones sensor data to understand driving behavior, like phone handling, aggressive braking, and vehicle crashesn- autonomously starts detecting at trip startn- uploads data to servers for reporting and analytics",
    "homepage": "https://github.com/apiosys/SfaraSDK",
    "license": {
        "type": "Commericial",
        "file": "LICENSE.md"
    },
    "authors": {
        "Sfara": "[email protected]"
    },
    "social_media_url": "https://twitter.com/sfara_co",
    "platforms": {
        "ios": "8.3"
    },
    "source": {
        "git": "https://github.com/apiosys/SfaraSDK.git",
        "tag": "3.0.0"
    },
    "source_files": "include/SfaraSDK/*.h",
    "resources": "SfaraSDK.bundle",
    "vendored_libraries": "libSfaraSDK.a",
    "preserve_paths": [
        "README.md",
        "LICENSE.md"
    ],
    "requires_arc": true,
    "frameworks": [
        "UIKit",
        "Foundation",
        "SystemConfiguration",
        "MobileCoreServices",
        "CoreLocation"
    ],
    "libraries": "c++",
    "dependencies": {
        "Godzippa": []
    }
}

Pin It on Pinterest

Share This