How to integrate Pinterest in ios application
Asked Answered
R

1

14

I want to integrate pinterest in my application. i want to add button of pinterest in my app through which i can upload image on pinterest I refer their Developers site but it doesnt help me.

I include SDK and tried their code but it doesnt work for me.

  #import <Pinterest/Pinterest.h>

UIButton* pinItButton = [Pinterest pinItButton];
    [pinItButton addTarget:self
                    action:@selector(pinIt:)
          forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:pinItButton];

 - (void)pinIt:(id)sender
    {
        [_pinterest createPinWithImageURL:@"http://placekitten.com/500/400"
                                sourceURL:@"http://placekitten.com"
                              description:@"Pinning from Pin It Demo"];
    }

please any help will be appreciated.

Thanks in advance.

Rickettsia answered 9/6, 2013 at 16:8 Comment(0)
V
30

I dont understand whats your actual problem but here i provide some easy step to integrate pinterest to your app

step : 1 Register for a Client ID from here

step : 2 Download the SDK from here and drag and drop into your project.

step : 3 You will then need to add a URL type to support opening your app from the Pinterest app , so add URL type to your plist file

Example if your client id is 18571937652947:
pin18571937652947 is the URL Scheme you need to support.

step : 4 To use the Pinterest framework you will need to import it into your file.

 #import <Pinterest/Pinterest.h>

and declare its object in your .h file

 Pinterest *pinterest

step : 5 initialise Pinterest object

 pinterest = [[Pinterest alloc]initWithClientId:@"your app client id"]

step : 6 To use the standard PinIt Button in a view add it as so:

 UIButton* pinItButton = [Pinterest pinItButton];
    [pinItButton addTarget:self
                    action:@selector(pinIt:)
          forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:pinItButton];

step : 7 You will need to handle the action an example of this is below:

- (void)pinIt:(id)sender
{
    NSURL *imageURL     = [NSURL URLWithString:@"http://placekitten.com/500/400"];
    NSURL *sourceURL    = [NSURL URLWithString:@"http://placekitten.com"];


    [pinterest createPinWithImageURL:imageURL
                           sourceURL:sourceURL
                         description:@"Pinning from Pin It Demo"];
}

Note : pinterest app should be installed in your device otherwise this code redirect to itunes to download pinterest app

Vallee answered 9/6, 2013 at 16:32 Comment(9)
Similar directons on Pinterest website can be found here too: developers.pinterest.com/iosNiigata
Ya but there are some point missing in doc. Like initialization of pinterest object.Vallee
@pratikbhiyani can we redirect app to pinterest website in browser instead of pinterest application?Zosi
@pratikbhiyani, so, I can't share via my app, only with pinterest app help? oh...Tiernan
@pratikbhiyani where place on application pin18571937652947 is the URL Scheme you need to support. i am new please help.Campeche
you need to set it in .plist fileVallee
Download the SDK from here and drag and drop into your project. its give error nothing to download here??????????what to doUnicycle
using thi surl:- NSURL *imageURL = [NSURL URLWithString:@"placekitten.com/500/400"]; NSURL *sourceURL = [NSURL URLWithString:@"placekitten.com"]; nothing happend its not open pintrestUnicycle
its give error canOpenURL: failed for URL: "pinit://" - error: "This app is not allowed to query for scheme pinit"Unicycle

© 2022 - 2024 — McMap. All rights reserved.