Open avi-mastov opened 4 years ago
I found the cause: I had Facebook SDK integration where I needed to override the app delegate's openURL method, so it didn't pass the call to uni_links plugin's method. I had to change my code as follows:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
];
if (!handled) {
handled = [[UniLinksPlugin sharedInstance] application:application openURL:url options:options];
}
return handled;
}
I didn't find any instructions in uni_links documentation regarding integration code in application: openURL:options:
. Please add it.
Thank you!
Will do. Thanks for the help.
Is it still have to change code?
@avi-mastov Can you give me more information? I have same error.. How cam i fix it?
@cyc2303 If you have some other SDK that causes override of the application:openURL:options:
, then you need to add a code similar to what I wrote above. Replace the FBSDKApplicationDelegate
statement with whatever is written there now. Open your AppDelegate class and look for that method.
If it's not there, and you still have this problem, then you may be using another SDK that does swizzling (overriding implementation in runtime) like Firebase does for notifications (not deep links, don't worry), and you need to look in that SDK's documentation how to disable swizzling and override manually.
@avi-mastov Thank you for your help. Finally I fixed it!
Can confirm exact what @avi-mastov said. We have snapchat login integration and the same problem.
import uni_links
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
var handled:Bool = SCSDKLoginClient.application(app, open: url, options: options);
if(!handled){
handled = UniLinksPlugin.sharedInstance().application(app, open: url, options: options);
}
return handled;
}
Thank @avi-mastov @pawlowskim Update small, simple solution:
Remember import: import uni_links
I think it needs more guidance in the documentation.
The above solution didn't work for me. Any idea why so?
Wow thank you so much guys, indeed, when using third party applications for login that overwrite AppDelegate functions, uni_links doesn't trigger any entering links on iOS. Thank you for the solution.
// in ios/Runner/AppDelegate.swift
import uni_links
// ...
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
if UniLinksPlugin.sharedInstance().application(app, open: url, options: options) {
return true
}
return false
}
In my case it was that I was awaiting getInitialUri()
before starting to listen to the stream, which, I imagine, was making me miss the initial emission. Registering a listener before checking for initial URI fixed it.
Might be a good idea to update the example code in the docs/README, as it suggests checking for initial URL first.
The above solution didn't work for me. Any idea why so?
Where you able to resolve this? I need assistance as I am facing the same issue
Describe the bug getInitialUri is working on both platforms and getUriLinksStream works on Android, but I don't get any events from getUriLinksStream and getLinksStream on iOS.
To Reproduce Steps to reproduce the behavior:
xcrun simctl openurl booted "custom_scheme://my_url"
xcrun simctl openurl booted "custom_scheme://my_url"
Expected behavior
adb shell am start -W -a android.intent.action.VIEW -d custom_scheme://my_url my.package.name
, everything works as expected, so I assume my integration was correct.Smartphone (please complete the following information):
Additional context