Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linkedin SDK issue in ios

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

like image 359
hitesh landge Avatar asked Oct 07 '15 11:10

hitesh landge


3 Answers

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;

}
like image 138
saugat gautam Avatar answered Oct 14 '22 03:10

saugat gautam


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

like image 2
Sujay Avatar answered Oct 14 '22 04:10

Sujay


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
        }
like image 2
Usama Sadiq Avatar answered Oct 14 '22 02:10

Usama Sadiq