i am using Linkedin SDK in ios. i am using following code to authenticate the user
[LISDKSessionManager createSessionWithAuth:[NSArray arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION, LISDK_EMAILADDRESS_PERMISSION, nil]
state:nil//@"some state"
showGoToAppStoreDialog:YES
successBlock:^(NSString *returnState) {
}
errorBlock:^(NSError *error) {
}
];
by using this code , i am able to open linkedin app but unable to get callback from linkedin app to my app. Not Getting call on
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
NSLog(@"%s url=%@","app delegate application openURL called ", [url absoluteString]);
if ([LISDKCallbackHandler shouldHandleUrl:url]) {
return [LISDKCallbackHandler application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}
return YES;
}
i am using "liMY_APPID" in URL Schemes.And also try from LinkedIn iOS SDK Bundle Suffix Please help me how i can get callback from linkedin app
Make sure if you are using iOS 9.0 or higher as base SDK since
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
is deprecated from iOS 9. Instead use
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<NSString *,
id> *)options
Use options[UIApplicationLaunchOptionsSourceApplicationKey]
and options[UIApplicationLaunchOptionsAnnotationKey]
for sourceApplication and annotation respectively.
Example:
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
if ([LISDKCallbackHandler shouldHandleUrl:url]) {
return [LISDKCallbackHandler application:app openURL:url sourceApplication:options[UIApplicationLaunchOptionsSourceApplicationKey] annotation:options[UIApplicationLaunchOptionsAnnotationKey]];
}
return YES;
}
Your code is correct only but your problem is related to URL schemes...
Add the same URL scheme in your info.plist
file what you have mentioned in "iOS URL Suffix Schemes" so that once linkedIn will call the same URL scheme, Might be you have used incorrect URL scheme in your app.
URL scheme is nothing but it is a link to open your application. If you enter your URL scheme in mobile safari i.e.
testApp://
it will open your app (If installed). Using following process you can add it in your project
right-click on your info.plist
and choose Open As – Source Code:
right-click on your info.plist
and select Show Raw Keys/Values, the output will look as follows:
check link for more details to add custom URL schemes
ISSUE RESOLVED
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
if LISDKCallbackHandler.shouldHandle(url) {
LISDKCallbackHandler.application(app, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])
}
return true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With