The app is in ionic, angular and capacitor. It works perfectly fine in Android, where i recieve the dynamic links in my app.component.ts function directly , but in ios the url are only in the AppDelegate.swift file It is correctly being open by a dynamic link, but once in the functions in appdelegate
Appdelegate.swift
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
// Called when the app was launched with an activity, including Universal Links.
// Feel free to add additional processing here, but if you want the App API to support
// tracking app url opens, make sure to keep this call
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)
}
}
if linkHandled {
return true
}else {
return false
}
}
i can't handle to send the user to a view like in approuting.ts or to send the url to my app.component.ts where i can handle it correctly. Do you know how can i do it?
Appdelegate.swift
func handleIncomingDynamicLink(_ dynamicLink: DynamicLink) {
guard let url = dynamicLink.url else {
print("That's weird, my dynamic object has no URL")
return
}
print("Your incoming link parameter is \(url.absoluteString)")
// Handle the dynamic link URL here
// You can extract parameters and navigate to specific screens based on the URL structure
// For example, you can use URL components to extract path components or query parameters
// Example:
let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false)
print("Your parameter is \(url.pathComponents)")
print("Your parameter isss \(urlComponents?.path)")
let notificationName = Notification.Name("MyAppDeepLinkNotification")
NotificationCenter.default.post(name: notificationName, object: url)
if let path = urlComponents?.path {
if path.hasPrefix("/category/") {
let venueID = path.replacingOccurrences(of: "/category/", with: "")
print("The url is for category \(id)")
app.component.ts
An example of how it works correctly in Android, but in ios i never receive the url
this.deeplinks.route({
] '/category/:id': CategoryPage,
Im trying to receive the dynamic link in my app.component.ts. The iOS configuration should be fine because my app is being opened and I receive them in AppDelegate.swift