Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share image in Pinterest using latest iOS SDK

Tags:

I want to share the image in Pinterest. I have configured Pinterest iOS SDK without CocoaPods.

I have written code that is making me to redirect to Pinterest app and getting authorisation. But after that I didn't get any response.

In previous version of iOS SDK, we have to only pass the url of that image. But now it is asking Board id also.

I don't know how to get the board id and share the image in Pinterest since I am not getting any response from success block.

This is the code I am using.

[[PDKClient sharedInstance] authenticateWithPermissions:[NSArray arrayWithObjects:PDKClientReadPublicPermissions, nil] withSuccess:^(PDKResponseObject *responseObject) {  

        NSLog(@"Response Object:%@",responseObject);

    } andFailure:^(NSError *error) {

        NSLog(@"Error:%@",error);
}];

I am trying it for past one week. Please suggest me where I am doing mistakes.

Thank you.

like image 200
Boominadha Prakash M Avatar asked Mar 17 '16 10:03

Boominadha Prakash M


1 Answers

I solved this issue and I would like to say thank you to the people who helped me. Now, I can share the image in Pinterest. I have referred the example app from this Github link https://github.com/pinterest/ios-pdk to share the image in Pinterest. Here is the steps I followed.

1) I installed the Pinterest SDK using Cocoapods.

2) I have added the below line in didFinishLaunchingWithOptions

[PDKClient configureSharedInstanceWithAppId:@"1234566"];

3) I have added the below two functions in AppDelegate.m file

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    return [[PDKClient sharedInstance] handleCallbackURL:url];
}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options
{
    return [[PDKClient sharedInstance] handleCallbackURL:url];
}

4) I have added the below code in image share button action.

[PDKPin pinWithImageURL:[NSURL URLWithString:@"https://about.pinterest.com/sites/about/files/logo.jpg"] link:[NSURL URLWithString:@"https://www.pinterest.com"]
                   suggestedBoardName:@"Testing" note:@"The Pinterest Logo" withSuccess:^
               {
                   // weakSelf.resultLabel.text = [NSString stringWithFormat:@"successfully pinned pin"];
               }
                           andFailure:^(NSError *error)
               {
                   //weakSelf.resultLabel.text = @"pin it failed";
                   NSLog(@"Error:%@",error);

               }];
like image 108
Boominadha Prakash M Avatar answered Oct 12 '22 10:10

Boominadha Prakash M