List of all Iphone and Blackberry Development codes in a one click Iphone,objective C,xcode,blackberry Development,iOS Development

Friday, February 26, 2016

IOS LinkedIn Integration

 Add the linkedin sdk(this). Then on login button click, use the following code.
Dont forget to add the linkedin app id on info.plist file.

  [LISDKSessionManager createSessionWithAuth:[NSArray arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION, LISDK_EMAILADDRESS_PERMISSION, nil]
                                         state:@"some state"
                        showGoToAppStoreDialog:YES
                                  successBlock:^(NSString *returnState) {
                                     
                                      NSLog(@"%s","success called!");
                                      LISDKSession *session = [[LISDKSessionManager sharedInstance] session];
                                      NSLog(@"value=%@ isvalid=%@",[session value],[session isValid] ? @"YES" : @"NO");
                                      NSMutableString *text = [[NSMutableString alloc] initWithString:[session.accessToken description]];
                                      [text appendString:[NSString stringWithFormat:@",state=\"%@\"",returnState]];
                                      NSLog(@"Response label text %@",text);
                                     // NSString *session1 = text;
                                      self.lastError = nil;
                                      // retain cycle here?
                                   
                                      [[LISDKAPIHelper sharedInstance] apiRequest:@"https://www.linkedin.com/v1/people/~:(id,first-name,last-name,maiden-name,email-address,formatted-name,picture-url)"
                                                                           method:@"GET"
                                                                             body:[@"" dataUsingEncoding:NSUTF8StringEncoding]
                                                                          success:^(LISDKAPIResponse *response) {
                                   NSLog(@"success called %@", response.data);
                                                                             
                                     
                                    NSError *jsonError;
                                    NSData *objectData = [response.data dataUsingEncoding:NSUTF8StringEncoding];
                                    NSDictionary *json = [NSJSONSerialization JSONObjectWithData:objectData
                                                                                                                                   options:NSJSONReadingMutableContainers
                                                                                                                                     error:&jsonError];

                                                                             
                                                                             
                                                                          }
                                                                            error:^(LISDKAPIError *apiError) {
                                                                                NSLog(@"error called %@", apiError.description);
                                                                               
                                                                               
                                                                            }];
                                     
                                  }
                                    errorBlock:^(NSError *error) {
                                        NSLog(@"%s %@","error called! ", [error description]);
                                        self.lastError = error;
                                      
                                    }
     ];
    NSLog(@"%s","sync pressed3");