Skip to content

Commit d0d0454

Browse files
authored
Merge pull request #13 from lyft/fix-deeplinking
Fix deeplinking
2 parents f0650d0 + e705528 commit d0d0454

File tree

4 files changed

+37
-50
lines changed

4 files changed

+37
-50
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
`LyftSDK` adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [1.0.6](https://github.com/lyft/Lyft-iOS-sdk/releases/tag/1.0.6)
6+
7+
- Fix deeplinking with parameters
8+
59
## [1.0.5](https://github.com/lyft/Lyft-iOS-sdk/releases/tag/1.0.5)
610

711
- Fix User-Agent header field

LyftSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'LyftSDK'
3-
s.version = '1.0.5'
3+
s.version = '1.0.6'
44
s.summary = 'The official Lyft iOS SDK.'
55
s.homepage = 'https://github.com/lyft/lyft-iOS-sdk'
66
s.license = { :type => 'Apache', :file => 'LICENSE' }

Resources/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0.5</string>
18+
<string>1.0.6</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

Sources/LyftUI/LyftDeepLink.swift

Lines changed: 31 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ import UIKit
99
public enum LyftDeepLinkBehavior {
1010
case native
1111
case web
12-
12+
1313
fileprivate var baseUrl: URL? {
1414
switch self {
15-
case .native:
16-
return URL(string: "lyft://")
17-
18-
case .web:
19-
return URL(string: "https://ride.lyft.com/")
15+
case .native:
16+
return URL(string: "lyft://ridetype")
17+
18+
case .web:
19+
return URL(string: "https://ride.lyft.com/u")
2020
}
2121
}
2222
}
2323

2424
/// Collection of deep links into the main Lyft application
2525
public struct LyftDeepLink {
26-
26+
2727
/// Prepares to request a ride with the given parameters
2828
///
2929
/// - parameter behavior: The deep linking mode to use for this deep link
@@ -36,59 +36,42 @@ public struct LyftDeepLink {
3636
to destination: CLLocationCoordinate2D? = nil,
3737
couponCode: String? = nil)
3838
{
39-
let action: String
4039
var parameters = [String: Any]()
4140
parameters["partner"] = LyftConfiguration.developer?.clientId
4241
parameters["credits"] = couponCode
43-
44-
switch behavior {
45-
case .native:
46-
action = "ridetype"
47-
parameters["id"] = kind.rawValue
48-
parameters["pickup[latitude]"] = pickup.map { $0.latitude }
49-
parameters["pickup[longitude]"] = pickup.map { $0.longitude }
50-
parameters["destination[latitude]"] = destination.map { $0.latitude }
51-
parameters["destination[longitude]"] = destination.map { $0.longitude }
52-
53-
case .web:
54-
action = "request"
55-
parameters["ride_type"] = kind.rawValue
56-
parameters["pickup"] = pickup.map { "@\($0.latitude),\($0.longitude)" }
57-
parameters["destination"] = destination.map { "@\($0.latitude),\($0.longitude)" }
58-
}
59-
60-
self.launch(using: behavior, action: action, parameters: parameters)
42+
parameters["id"] = kind.rawValue
43+
parameters["pickup[latitude]"] = pickup.map { $0.latitude }
44+
parameters["pickup[longitude]"] = pickup.map { $0.longitude }
45+
parameters["destination[latitude]"] = destination.map { $0.latitude }
46+
parameters["destination[longitude]"] = destination.map { $0.longitude }
47+
48+
self.launch(using: behavior, parameters: parameters)
6149
}
62-
63-
private static func launch(using behavior: LyftDeepLinkBehavior, action: String,
64-
parameters: [String: Any])
50+
51+
private static func launch(using behavior: LyftDeepLinkBehavior, parameters: [String: Any])
6552
{
66-
guard let originalUrl = behavior.baseUrl.flatMap({ URL(string: action, relativeTo: $0) }) else {
67-
return
68-
}
69-
70-
let request = lyftURLEncodedInURL(request: URLRequest(url: originalUrl), parameters: parameters).0
53+
let request = lyftURLEncodedInURL(request: URLRequest(url: behavior.baseUrl!), parameters: parameters).0
7154
guard let url = request.url else {
7255
return
7356
}
74-
57+
7558
switch behavior {
76-
case .native:
77-
if #available(iOS 10.0, *) {
78-
UIApplication.shared.open(url, options: [:]) { success in
79-
if !success {
80-
self.launchAppStore()
81-
}
59+
case .native:
60+
if #available(iOS 10.0, *) {
61+
UIApplication.shared.open(url, options: [:]) { success in
62+
if !success {
63+
self.launchAppStore()
8264
}
83-
} else {
84-
UIApplication.shared.openURL(url)
8565
}
86-
87-
case .web:
88-
Safari.openURL(url, from: UIApplication.shared.topViewController)
66+
} else {
67+
UIApplication.shared.openURL(url)
68+
}
69+
70+
case .web:
71+
Safari.openURL(url, from: UIApplication.shared.topViewController)
8972
}
9073
}
91-
74+
9275
@available(iOS 10.0, *)
9376
private static func launchAppStore() {
9477
let signUp = LyftConfiguration.signUpIdentifier
@@ -108,7 +91,7 @@ fileprivate extension UIApplication {
10891
while let viewController = topController?.presentedViewController {
10992
topController = viewController
11093
}
111-
94+
11295
return topController
11396
}
11497
}

0 commit comments

Comments
 (0)