Pinterest SDK integrates in iOS apps

Samsul Hoque
4


step : 1 Register for a Client ID from here
step : 2 Install the SDK 
The SDK is a cocoapod, so you’ll need a podfile for your app before you begin. To install the SDK:
  1. Open your Podfile and add the following dependency in the target “<your-app>” do section:
    pod “PinterestSDK”, :git => “git@github.com:pinterest/ios-pdk.git”
    
  2. OR
  3. pod "PinterestSDK", :git => "https://github.com/pinterest/ios-pdk.git"
  4. Save your Podfile.
  5. Run pod install from the command line. You've now installed the iOS SDK.


step : 3 Configure Xcode
You’ll need to configure .plist on your project in order to redirect back to your app after authentication. Do this by adding a URL scheme to your .plist.
In Xcode, right-click your .plist and select Open As > Source Code. Copy and paste the following code inside the <dict>...</dict>, replacing {your-app-id} with your App ID.
<key>CFBundleURLTypes</key>
  <array>
    <dict>
      <key>CFBundleURLName</key>
      <string></string>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>pdk{your-app-id}</string>
      </array>
    </dict>
  </array>

step : 4 Configure the PDK Client

Finally, you’ll need to link your App ID to the PDK Client in your app.

[PDKClient configureSharedInstanceWithAppId:@"12345"];

step : 5 To use the Pinterest framework you will need to import it into your file.
 #import "PDKPin.h"

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

UIButton *pinItButton = [UIButton buttonWithType:UIButtonTypeSystem];
pinItButton.translatesAutoresizingMaskIntoConstraints = NO;
[pinItButton setTitle:NSLocalizedString(@"PinIt", nil) forState:UIControlStateNormal];
[pinItButton addTarget:self action:@selector(pinItButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:pinItButton];
step : 7 You will need to handle the action an example of this is below:

- (void)pinItButtonTapped:(UIButton *)button
  {

  [PDKPin pinWithImageURL:[NSURL URLWithString:@"http://placekitten.com/500/400"]
                   link:[NSURL URLWithString:@"https://www.pinterest.com"]
     suggestedBoardName:@"ABC-XYZ"
                   note:@"The Pinterest Logo"
            withSuccess:^
 {
     NSLog(@"successfully pinned pin");

 }
             andFailure:^(NSError *error)
 {
            NSLog(@"pin it failed");

 }];
}

Note : If plist file was missing the BundleDisplayName. In order to solve this problem you just need to add it to the plist file.

<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>



Post a Comment

4Comments
  1. I am a professional blogger, and I value Pinterest a lot. The reason I can say this proudly is because I use PinPinterest com as my Pinterest account automation. PinPinterest is so amazing that I can schedule my posts according to my desired time and I don’t need to be online all day for that too. A mobile-friendly awesome tool for Pinterest.

    ReplyDelete
Post a Comment