Problem with Linkedin SDK in ios

I am using the Linkedin SDK in ios. I use the 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) { } ]; 

using this code, I can open the linkedin application, but could not get a callback from the linkedin application to my application. Do not receive a call

 - (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 use "liMY_APPID" in URL schemes. And also try LinkedIn iOS SDK Bundle Suffix Please help me how can I get a callback from a related application.

+5
source share
5 answers

Make sure you use iOS 9.0 or higher as the base SDK, as

 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation 

deprecated from iOS 9. Use instead

 - (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; } 
+6
source

Your code is correct, but your problem is with URL schemes ...


Add the same URL scheme to your info.plist file that you mentioned in the β€œ iOS URL suffix schemes ” so that after linkedIn calls the same URL scheme, you may have used the wrong URL scheme in your application.

enter image description here

A URL scheme is nothing more than a link to open your application. If you enter your URL scheme in mobile safari i.e.

TestApp: //

it will open your application (if installed). Using the following process, you can add it to your project

right-click on info.plist and select Open As - Source Code:

enter image description here

right-click on info.plist and select "Show Source Keys / Values", the output will look like this:

enter image description here

check link for more details to add custom URL schemes

+2
source

SELECTION OF RESULTS

  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 } 
+2
source

Have you added the LIAppId property to your Info.plist?

+1
source

Have you added all your packages to the LinkedIn link center for iOS? If not, copy the package ID and add it to https://www.linkedin.com/developer/apps/APP_ID/mobile and do not forget to Save .

0
source

Source: https://habr.com/ru/post/1233142/


All Articles