Dynamic Links Firebase Function Not Being Called at All Xcode 12

Dynamic Links Firebase function not being called at all Xcode 12?

SwiftUI 1.0 / SceneDelegate

You do the same but in your SceneDelegate, following callback:

func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
if let incomingURL = userActivity.webpageURL {
print("Incoming URL is \(incomingURL)")
let linkHandled = DynamicLinks.dynamicLinks().handleUniversalLink(incomingURL) { (dynamicLink, error) in
guard error == nil else{
print("Found an error! \(error!.localizedDescription)")
return
}
if let dynamicLink = dynamicLink {
self.handleIncomingDynamicLink(dynamicLink)
}
}
}

SwiftUI 2.0 / WindowGroup

With SwiftUI 2.0 life-cycle you need to use instead .onContinueUserActivity, like

WindowGroup {
ContentView()
.onContinueUserActivity(<your_activity_type_here>) { userActivity in
if let incomingURL = userActivity.webpageURL {
print("Incoming URL is \(incomingURL)")
let linkHandled = DynamicLinks.dynamicLinks().handleUniversalLink(incomingURL) { (dynamicLink, error) in
guard error == nil else{
print("Found an error! \(error!.localizedDescription)")
return
}
if let dynamicLink = dynamicLink {
self.handleIncomingDynamicLink(dynamicLink)
}
}
}
}
}

Firebase dynamic links are not working on iOS when the dynamic link has the custom subdomain

It's because I was using FirebaseDynamicLinks 1.4.0 which is old. When I update to FDL library 3.0.1, dynamic links with custom subdomain are working fine in the app.

The reason why I believed that I was using the latest FDL library and
couldn't identify that I was using old FDL library is, CocoaPods(a
dependency manager for iOS projects, read more) couldn't get me
the latest version of FirebaseDynamicLinks for some reason, no matter
what I do like remove and reinstall FirebaseDynamicLinks from Pod file
or run pod update command. So, I have removed FirebaseDynamicLinks
from pod file and ran the command pod install, it removed that library
from my project and now I have downloaded FirebaseDynamicLinks
framework from firebase console and integrated it manually on my
project. Now with the new FirebaseDynamicLinks SDK, dynamic links with
custom subdomain are working fine in the app.

Firebase Deeplink not calling application:continueUserActivity:restorationHandler function of AppDelegate in Swift 3

I also have same issue, you need to get NSUserActivity from launchOptions

var launchURL :URL? = nil

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
....
// this code should have worked but not working for me with Xcode 9
// if let userActivityDictionary = launchOptions?[.userActivityDictionary] as? [UIApplicationLaunchOptionsKey : Any],
// let auserActivity = userActivityDictionary[.userActivityType] as? NSUserActivity {
// launchURL = auserActivity.webpageURL
// }

if let userActDic = launchOptions?[UIApplicationLaunchOptionsKey.userActivityDictionary] as? [String: Any],
let auserActivity = userActDic["UIApplicationLaunchOptionsUserActivityKey"] as? NSUserActivity{

NSLog("type \(userActDic.self),\(userActDic)") // using NSLog for logging as print did not log to my 'Device and Simulator' logs
launchURL = auserActivity.webpageURL
}
...
}

func applicationDidBecomeActive(_ application: UIApplication) {
if let url = self.launchURL {
self.launchURL = nil

DispatchQueue.main.asyncAfter(deadline: .now()+2.0, execute: {
// wait to initalize notifications

if let dynamicLinks = DynamicLinks.dynamicLinks() {
NSLog("handling \(dynamicLinks)")
dynamicLinks.handleUniversalLink(url) { (dynamiclink, error) in
if let link = dynamiclink?.url {
NSLog("proceessing \(dynamicLinks)")
let strongMatch = dynamiclink?.matchConfidence == .strong
// process dynamic link here
self.processDynamicLink(withUrl: link, andStrongMatch: strongMatch)
}
}

}

})
}

}

iOS Application: Firebase Dynamic Links are not working with latest Pod file

In iOS 13, AppDelegate methods will not call. Add SceneDelegate to your project. Add
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
print(userActivity.webpageURL)
}

we will get userActivity.webpageURL will be our long dynamic link.

Firebase dynamic link not opening iOS app

Steps:

  1. Delete your app
  2. Restart your device.
  3. Reinstall your app and test.

As per firebase, sometimes error comes while downloading "apple-app-site-association" file associated with your domain. That's why it happens.

Check out this video: https://youtu.be/KLBjAg6HvG0?t=483 for debugging help.

Setup Dynaminc link from start: https://www.youtube.com/watch?v=KLBjAg6HvG0

If you have completed the above-mentioned steps, please check if you have the right methods implemented in your AppDelegate file.

Method 1:

    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if DynamicLinks.dynamicLinks().shouldHandleDynamicLink(fromCustomSchemeURL: url) {
let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url)
self.handleDynamicLink(dynamicLink)
return true
}

return true
}

Method 2:

    func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if let incomingURL = userActivity.webpageURL {
print(incomingURL)

let linkHandled = DynamicLinks.dynamicLinks().handleUniversalLink(incomingURL) { (dynamicLink, error) in
guard error == nil else {
print("Found an error! \(error!.localizedDescription)")
return
}

if let dynamicLink = dynamicLink {
self.handleDynamicLink(dynamicLink)
}
}

if linkHandled {
return true
} else {
//May be do other things with our incoming URL?
return false
}
}

return false
}

Handle Dynamic Link common Method:

    func handleDynamicLink(_ dynamicLink: DynamicLink?) {
guard let dynamicLink = dynamicLink else { return }
guard let deepLink = dynamicLink.url else { return }

}


Related Topics



Leave a reply



Submit