I'm having a hard time with the implementation of BitlySDK for iOS 18 for the POC (don't have published app yet, currently only on TestFlight).
I have followed the documentation from Bitly (which seems to be deprecated and lacking info in general about mobile deep links):
Expected behavior
Actual behavior:
Am I missing some part of configuration or doing something wrong?
AppDelegate.swift:
import Foundation
import BitlySDK
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
Bitly.initialize("BITLY_APP_ID", supportedDomains:["CUSTOM_DOMAIN"], supportedSchemes: [""]) { response, error in
// response provides a BitlyResponse object which contains the full URL information
// response includes a status code
// error provides any errors in retrieving information about the URL
// Your custom logic goes here...
if let deepLink = response?.url {
print("✅ Received deep link: \(deepLink)")
if let url = URL(string: deepLink) {
DeepLinkManager.shared.handle(url: url)
}
} else {
DispatchQueue.main.async {
DeepLinkManager.shared.page = "Response not called"
}
}
}
return true
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
return Bitly.handle(userActivity)
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
return Bitly.handleOpen(url)
}
}
Thanks to Fatima's comment, I'm closing the question with the solution:
Instead of using these functions in AppDelegate (as instructed in BitlySDK):
application(_:continue:restorationHandler:)
application(_:open:options:)
Use view modifiers to receive NSUserActivity and URLs:
onContinueUserActivity(_:perform:)
onOpenURL(perform:)