Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS application integration with pinterest [closed]

Tags:

What is the most reliable way currently to allow pinterest sharing from iOS app?

Pinterest API is not public yet and only suggested way to share is their web button.

like image 924
Peter Prokop Avatar asked Mar 28 '12 14:03

Peter Prokop


People also ask

How do I get my application to show up in the open in menu on iOS for a specific document type?

Tap and hold the document attachment icon. This should open a popover on the iPad, or an action sheet on the iPhone, that shows all of the apps that open your document type. Your app should show up in the list. Tap your app icon and your app should launch and receive the document from the email.

Does Pinterest work on iPhone?

Pinterest, Inc. Requires iOS 13.0 or later. Requires iPadOS 13.0 or later. Requires iOS 13.0 or later.

Does Pinterest have an iPad app?

Pinterest for iOS and Android is available for free on iTunes and Google Play, respectively.

How do I pin an app on Pinterest on iOS?

You must also have the (free) Pinterest app installed on your iOS device. Once installed, you can search the App Store for the app you want to Pin. When you find it, tap on it to bring up the "details" view, as shown in the image below.

What's new on Pinterest for iOS 14?

Tapping into the iOS-14-inspired trend of customized home-screens, Pinterest has today launched a new Pinterest widget for iOS 14, which enables Pinners to feature a board of their own, or one they follow, on their iPhone home screen.

How do I add a Pinterest widget to my screen?

To add the new Pinterest widget: Hold an area on your screen and tap the plus sign in the upper-left corner to choose from widgets Select the widget’s size and add to your home screen Select a board of yours or one you follow


2 Answers

I made a pinterest integration in my iPad app. But, because Pinterest doesn't have an API for posting yet, I used the following method. I just create programmatically an HTML Web Page and add a Pin it button to that page programmatically. Then I show a Web View and allow user to click Pin it once more. These are more explained steps.

1) Create a WebViewController, that has a UIWebView. Add Close button, add UIWebViewDelegateProtocol, spinner, htmlString property.

2) Generate an HTML programmatically to put to that UIWebView, when user clicks your "Pin it" button in your app. In this case I put to the HTML page different images for different products.

- (NSString*) generatePinterestHTMLForSKU:(NSString*)sku {
NSString *description = @"Post your description here";

// Generate urls for button and image
NSString *sUrl = [NSString stringWithFormat:@"http://d30t6wl9ttrlhf.cloudfront.net/media/catalog/product/Heros/%@-1.jpg", sku];
NSLog(@"URL:%@", sUrl);
NSString *protectedUrl = (__bridge NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,(__bridge CFStringRef)sUrl, NULL, (CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ",CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding));
NSLog(@"Protected URL:%@", protectedUrl);
NSString *imageUrl = [NSString stringWithFormat:@"\"%@\"", sUrl];
NSString *buttonUrl = [NSString stringWithFormat:@"\"http://pinterest.com/pin/create/button/?url=www.flor.com&media=%@&description=%@\"", protectedUrl, description];

NSMutableString *htmlString = [[NSMutableString alloc] initWithCapacity:1000];
[htmlString appendFormat:@"<html> <body>"];
[htmlString appendFormat:@"<p align=\"center\"><a href=%@ class=\"pin-it-button\" count-layout=\"horizontal\"><img border=\"0\" src=\"http://assets.pinterest.com/images/PinExt.png\" title=\"Pin It\" /></a></p>", buttonUrl];
[htmlString appendFormat:@"<p align=\"center\"><img width=\"400px\" height = \"400px\" src=%@></img></p>", imageUrl];
[htmlString appendFormat:@"<script type=\"text/javascript\" src=\"//assets.pinterest.com/js/pinit.js\"></script>"];
[htmlString appendFormat:@"</body> </html>"];
return htmlString;
}

This is an example of my HTML page generation method.

3) Create a method to call when user taps your "Pin it" button, which shows that webView with the image, that you will post and the "Pin it" button on the UIWebView. This is my example:

- (void) postToPinterest {

NSString *htmlString = [self generatePinterestHTMLForSKU:self.flProduct.sku];
NSLog(@"Generated HTML String:%@", htmlString);
WebViewController *webViewController = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:nil];
webViewController.htmlString = htmlString;
webViewController.showSpinner = YES;

[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentModalViewController:webViewController animated:YES];
}

4) Put a "Close" button to your WebViewController to close it. Also you can add spinners to track the loading of the UIWebView.

- (IBAction)closeClicked:(id)sender {
[self dismissModalViewControllerAnimated:YES];

}

- (void)webViewDidStartLoad:(UIWebView *)webView {
if (showSpinner) {
    // If we want to show Spinner, we show it everyTime
    [UIHelper startShowingSpinner:self.webView];
}
else {
    // If we don't -> we show it only once (some sites annoy with it)
    if (!spinnerWasShown) {
        [UIHelper startShowingSpinner:self.webView];
        spinnerWasShown = YES; 
    }
}
}

-(void)webViewDidFinishLoad:(UIWebView *)webView {
    [UIHelper stopShowingSpinner];
}

P.S. I used the same method to add Google Plus's +1 button to the iPad app. (It doesn't have posting API too, only readonly API at the moment)

like image 128
Denis Kutlubaev Avatar answered Sep 21 '22 03:09

Denis Kutlubaev


If you only want to share(i.e. pin on a user board), then you can use iphone-URL-Scheme and call the Pinterest application along with the parameters url(URL of the page to pin), media(URL of the image to pin) & description(Description of the page to be pinned). Present a UIAlertView and forward them to appstore to download the official Pinterest application if the user has not installed it.

Reference: http://wiki.akosma.com/IPhone_URL_Schemes#Pinterest

Code to open Pinterest Applicaiton:

NSURL *url = [NSURL URLWithString:@"pinit12://pinterest.com/pin/create/bookmarklet/?url=URL-OF-THE-PAGE-TO-PIN&media=URL-OF-THE-IMAGE-TO-PIN&description=ENTER-YOUR-DESCRIPTION-FOR-THE-PIN"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
    [[UIApplication sharedApplication] openURL:url];
}else {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Pinterest" message:@"Would you like to download Pinterest Application to share?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Continue", nil];
    [alert show];
}

UIAlertViewDelegate Method

- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 1){
        NSString *stringURL = @"http://itunes.apple.com/us/app/pinterest/id429047995?mt=8";
        NSURL *url = [NSURL URLWithString:stringURL];
        [[UIApplication sharedApplication] openURL:url];
    }
}
like image 28
John Melvin Avatar answered Sep 22 '22 03:09

John Melvin