Linkedin SDK issue in ios
Asked Answered
C

5

5

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

Coorg answered 7/10, 2015 at 11:16 Comment(2)
Did you figure out the solution?Outrelief
check my answer . I reslove it successfullyDeas
N
7

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;

}
Nates answered 24/11, 2015 at 11:55 Comment(0)
U
2

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.

enter image description here

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:

enter image description here

right-click on your info.plist and select Show Raw Keys/Values, the output will look as follows:

enter image description here

check link for more details to add custom URL schemes

Unicuspid answered 25/2, 2016 at 19:54 Comment(1)
is it only possible with Linkedin v1?Marmoset
D
2

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
        }
Deas answered 1/8, 2017 at 13:48 Comment(0)
P
1

Did you add the LIAppId property to your Info.plist?

Penninite answered 17/10, 2015 at 22:54 Comment(1)
If you're using url scheme suffix, make sure it is specified in the Info.plist. The key should be "LISuffix" and the value should be the suffix. Also, register a url scheme with the format li<appId>-<suffix>Penninite
R
-1

Have you added all your bundles to LinkedIn dev's center for iOS? If not, copy your bundle id and add it to https://www.linkedin.com/developer/apps/APP_ID/mobile and do not forget to Save.

Randi answered 8/10, 2015 at 22:21 Comment(2)
All bundles entry is correct.And given link is not opening.Coorg
I have the same issue. Everything is correctly filled in but the LinkedIn app does not return control to my app.Laminitis

© 2022 - 2024 — McMap. All rights reserved.