Reputation: 164
I am using following method to implement deep linking.
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
When app is in background this method is not calling when I came from browser?.
I have added all required procedures to implement deep linking.
How to solve this ?
Upvotes: 0
Views: 2014
Reputation: 5555
#define App_Scheme @"yourbundleappschme"
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([[url scheme] isEqualToString:App_Scheme])
{
NSLog(@"Calling Application Bundle ID: %@", sourceApplication);
NSLog(@"URL scheme:%@", [url scheme]);
NSLog(@"URL query: %@", [url query]);
return YES;
}
return NO;
}
Also Add in Delegate
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options {
//handle here
if ([[url scheme] isEqualToString:App_Scheme])
{
NSLog(@"URL scheme:%@", [url scheme]);
NSLog(@"URL query: %@", [url query]);
return YES;
}
return FALSE;
}
Also add Project - > Target - > Capabilites -> Associated Domains -> Add your domain with
App links: domain here
Upvotes: 0
Reputation: 45
try this.
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
guard let dynamicLinks = FIRDynamicLinks.dynamicLinks() else {
return false
}
let handled = dynamicLinks.handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
print(error as Any)
}
return handled
}
Upvotes: 1