GithubHelp home page GithubHelp logo

isabella232 / lyft-ios-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lyft/lyft-ios-sdk

0.0 0.0 0.0 85 KB

Public Lyft SDK for iOS

License: Other

Swift 98.11% Ruby 1.37% Makefile 0.52%

lyft-ios-sdk's Introduction

Lyft iOS SDK

The Official Lyft iOS SDK makes it easy to integrate Lyft into your app. More specifically, it provides:

  • An easily configurable Lyft button which can display cost, ETA, and ride type. Tapping the button deeplinks into the Lyft app with pre-filled pickup/destination/ridetype.
  • A swift interface for making async calls to Lyft's REST APIs
  • A sample iOS project that shows how to use the SDK components.

Registration

  • You must first create a Lyft Developer account here.
  • Once registered, you will be assigned a Client ID and will be able to generate Client Tokens.

Installation

Embedded frameworks require a minimum deployment target of iOS 8 or OS X Mavericks (10.9).

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 0.39.0+ is required to build LyftSDK.

To integrate LyftSDK into your Xcode project using CocoaPods, specify it in your Podfile:

platform :ios, '8.0'
use_frameworks!

pod 'LyftSDK'

Then, run the following command:

$ pod install

Installing without iOS specific UI elements

pod 'LyftSDK/API'

Carthage

Carthage is a simple, decentralized dependency manager for Cocoa. To import this SDK, add this to your Cartfile:

github "lyft/Lyft-iOS-sdk"

Integrate without dependency manager

Drag the LyftSDK.xcodeproj project into your project's Project Navigator. In your project's Build Target, click on the General tab and then under Embedded Binaries click the + button. Select the LyftSDK.framework under your project.

Usage

SDK Configuration

In your app, before using LyftSDK, be sure to configure your developer information using LyftConfiguration. This is preferably done in your UIApplicationDelegate's application:didFinishLaunchingWithOptions' as follows:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
	LyftConfiguration.developer = (token: "...", clientId: "...")
	// Complete other setup
	return true
}

Lyft Button

Adding the Lyft Button to a Storyboard or xib is as easy adding a new UIView to your superview and setting the class to LyftButton in the Identity Inspector tab. We recommend setting the width to 260p and the height to 50p. Please keep in mind that a smaller width/height may result in undesirable UI, such as cut off text.

ib-setup

To create the button programatically with its preferred size, simply call let lyftButton = LyftButton()

Load ETA/cost

let pickup = CLLocationCoordinate2D(latitude: 37.7833, longitude: -122.4167)
let destination = CLLocationCoordinate2D(latitude: 37.7794703, longitude: -122.4233223)
lyftButton.configure(pickup: pickup, destination: destination)

Ride types

Lyft is growing very quickly and is currently available in these cities. Please keep in mind that some ride types (such as Lyft Line) are not yet available in all Lyft cities. If you set the ride type of the button and it happens to be unavailable, the button will default to the Lyft Classic ride type. You can utilize the LyftAPI.rideTypes(at:completion:) wrapper to get a list of the available ride types in an area.

Deep link behavior

When a user taps on the Lyft Button, the default behavior is to deep link into the native Lyft app with the configuration information you have provided.

However, if you would like to create a ride request on Lyft using Lyft's mobile web experience, you can specify the button's deepLinkBehavior as follows:

lyftButton.deepLinkBehavior = .web

This is preferable if you do not want the user to leave your app when making a ride request. Also, it does not require the user has Lyft installed.

Button styles

To specify the button style, use enum LyftButtonStyle

lyftButton.style = .MulberryDark

There are 5 styles to pick from:

lyft-styles

Lyft API Wrapper

The SDK provides wrapper methods around Lyft's REST APIs - this can be helpful when you want to build a more custom integration with the Lyft platform vs making HTTP requests directly.

let pickup = CLLocationCoordinate2D(latitude: 37.7833, longitude: -122.4167)
LyftAPI.ETAs(to: pickup) { result in
    result.value?.forEach { eta in
        print("ETA for \(eta.rideKind): \(eta.minutes) min")
    }
}

Deeplinking

The SDK provides direct deeplinking to the Lyft app for those developers who prefer to handle their own custom deeplinking vs relying on the Lyft Button.

let pickup = CLLocationCoordinate2D(latitude: 37.7833, longitude: -122.4167)
let destination = CLLocationCoordinate2D(latitude: 37.7794703, longitude: -122.4233223)
LyftDeepLink.requestRide(kind: .Standard, from: pickup, to: destination)

Note that you can specify a LyftDeepLinkBehavior in this request, to decide between deep linking to the native lyft app or launching Lyft's mobile web experience within your own app.

Support

If you're looking for help configuring or using the SDK, or if you have general questions related to our APIs, the Lyft Developer Platform team provides support through Stack Overflow (using the lyft-api tag)

Reporting security vulnerabilities

If you've found a vulnerability or a potential vulnerability in the Lyft iOS SDK, please let us know at [email protected]. We'll send a confirmation email to acknowledge your report, and we'll send an additional email when we've identified the issue positively or negatively.

lyft-ios-sdk's People

Contributors

acityinohio avatar ggurantz avatar servercimen avatar vpolouchkine avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.