Skip to content

Commit 9a7556d

Browse files
authored
fix didResolveDeepLink switch statement (#11)
* fix: update logic in switch statement to do more than just return in all cases * add deeplink delegate to example
1 parent e9aa4e1 commit 9a7556d

File tree

2 files changed

+14
-47
lines changed

2 files changed

+14
-47
lines changed

Example/BasicExample/BasicExample/BasicExampleApp.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import SwiftUI
99
import Segment
1010
import SegmentAppsFlyer
11+
import AppsFlyerLib
1112

1213
@main
1314
struct BasicExampleApp: App {
@@ -18,12 +19,21 @@ struct BasicExampleApp: App {
1819
}
1920
}
2021

22+
class DeepLinkManager: NSObject, DeepLinkDelegate {
23+
func didResolveDeepLink(_ result: DeepLinkResult) {
24+
print("Deep Link: \(result)")
25+
}
26+
}
27+
2128
extension Analytics {
2229
static var main: Analytics {
2330
let analytics = Analytics(configuration: Configuration(writeKey: "<YOUR WRITE KEY>")
2431
.flushAt(3)
2532
.trackApplicationLifecycleEvents(true))
26-
analytics.add(plugin: AppsFlyerDestination())
33+
34+
let deepLinkHandler = DeepLinkManager()
35+
let appsFlyer = AppsFlyerDestination(segDLDelegate: deepLinkHandler)
36+
analytics.add(plugin: appsFlyer)
2737
return analytics
2838
}
2939
}

Sources/SegmentAppsFlyer/AppsFlyerDestination.swift

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,13 @@ extension AppsFlyerDestination: DeepLinkDelegate, UIApplicationDelegate {
279279
segDLDelegate?.didResolveDeepLink?(result)
280280
switch result.status {
281281
case .notFound:
282+
analytics?.log(message: "AppsFlyer: Deep link not found")
282283
return
283284
case .failure:
285+
analytics?.log(message: "AppsFlyer: Deep link failure!")
284286
return
285287
case .found:
286-
return
288+
analytics?.log(message: "AppsFlyer Deep link found")
287289
}
288290

289291
guard let deepLinkObj:DeepLink = result.deepLink else { return }
@@ -323,54 +325,9 @@ extension AppsFlyerDestination: DeepLinkDelegate, UIApplicationDelegate {
323325
analytics?.track(name: "Direct Deep Link", properties: properties)
324326

325327
}
326-
327-
// Uncomment the following code and alter to fit your implementation in order
328-
// to collect deep linking attribution data
329-
330-
//Logic to grab AppsFlyer's deep link value to instantiate correct VC
331-
// guard let productNameStr = deepLinkObj.deeplinkValue else {
332-
// print("Could not extract deep_link_value from deep link object")
333-
// return
334-
// }
335-
336-
//implement your own logic to open the correct screen/content
337-
// walkToSceneWithParams(product: productNameStr, deepLinkObj: deepLinkObj)
338328
}
339-
340-
341-
// User logic for opening Deep Links
342-
// fileprivate func walkToSceneWithParams(product: String, deepLinkObj: DeepLink) {
343-
// let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
344-
// UIApplication.shared.windows.first?.rootViewController?.dismiss(animated: true, completion: nil)
345-
//
346-
// let destVC = "product_vc"
347-
// if let newVC = storyBoard.instantiateVC(withIdentifier: destVC) {
348-
//
349-
// print("[AFSDK] AppsFlyer routing to section: \(destVC)")
350-
// newVC.deepLinkData = deepLinkObj
351-
//
352-
// UIApplication.shared.windows.first?.rootViewController?.present(newVC, animated: true, completion: nil)
353-
// } else {
354-
// print("[AFSDK] AppsFlyer: could not find section: \(destVC)")
355-
// }
356-
// }
357329
}
358330

359-
//MARK: - UI StoryBoard Extension; Deep Linking
360-
361-
//Aditonal logic for Deep Linking
362-
//extension UIStoryboard {
363-
// func instantiateVC(withIdentifier identifier: String) -> DLViewController? {
364-
// // "identifierToNibNameMap" – dont change it. It is a key for searching IDs
365-
// if let identifiersList = self.value(forKey: "identifierToNibNameMap") as? [String: Any] {
366-
// if identifiersList[identifier] != nil {
367-
// return self.instantiateViewController(withIdentifier: identifier) as? DLViewController
368-
// }
369-
// }
370-
// return nil
371-
// }
372-
//}
373-
374331
private struct AppsFlyerSettings: Codable {
375332
let appsFlyerDevKey: String
376333
let appleAppID: String

0 commit comments

Comments
 (0)