Search code examples
iospostsharelinkedin-apipinterest

How to open Pinterest and Linked iOS app for share something?


I coding a iOS app, It need open Pinterest and LinkedIn to share something. (If user didn't install it, it will be open safari and share - post something).

I try to use some Schemes, but it didn't work. Maybe have anyway for do this.

I found some URL Schemes for share with Pinterest app. It worked for me:

NSString *sharingURL = [[NSString stringWithFormat:@"pinterestsdk.v1://pinit/?client_id=%@&source_url=%@&image_url=%@&app_name=%@&suggested_board_name=%@&description=%@",@"xxxxxxx", @"shareurl.com", @"shareurl.com/shareMedia.png", @"Your_App_Name", @"Board_Name", @"Your_Description"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:sharingURL]])
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:sharingURL]];
}

With LinkedIn, i researching for a best solution.

Oh, Maybe have way for share with LinkedIn app, when you press share on Safari browse, it have a option for LinkedIn, and it worked without signin (safari did not sign in LinkedIn before, just LinkedIn app.). But SDK of LinkedIn just support for REST API.

Thanks, sorry for my bad english.


Solution

  • Opening a Pinterest User Profile

    - (IBAction)openPinterestUser:(id)sender {
    
        // open the Pinterest App if available
        if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"pinterest://user/juliav1"]]) {
    
            // opening the app didn't work - let's open Safari
            if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.pinterest.com/versluis2000/"]]) {
    
                // nothing works - perhaps we're not online
                NSLog(@"Dang!");
            }
        }
    }
    

    Opening a Pinterest Board

    - (IBAction)openPinterestBoard:(id)sender {
    
        // open the Pinterest App if available
        if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"pinterest://board/versluis2000/ios-projects"]]) {
    
            // opening the app didn't work - let's open Safari
            if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.pinterest.com/versluis2000/ios-projects/"]]) {
    
                // nothing works - perhaps we're not online
                NSLog(@"Dang!");
            }
        }
    }
    

    Opening a Pinterest Pin

    - (IBAction)openPinterestPin:(id)sender {
    
        // open the Pinterest App if available
        if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"pinterest://pin/76279787413881109"]]) {
    
            // opening the app didn't work - let's open Safari
            if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.pinterest.com/pin/76279787413881109/"]]) {
    
                // nothing works - perhaps we're not online
                NSLog(@"Dang!");
            }
        }
    }
    

    Using Pintrest SDK

    Pin methods

    - (void)getPinWithIdentifier:(NSString *)pinId
                          fields:(NSSet *)fields
                     withSuccess:(PDKClientSuccess)successBlock
                      andFailure:(PDKClientFailure)failureBlock;
    
    - (void)createPinWithImageURL:(NSURL *)imageURL
                             link:(NSURL *)link
                          onBoard:(NSString *)boardId
                      description:(NSString *)pinDescription
                      withSuccess:(PDKClientSuccess)successBlock
                       andFailure:(PDKClientFailure)failureBlock;
    
    - (void)createPinWithImage:(UIImage *)image
                          link:(NSURL *)link
                       onBoard:(NSString *)boardId
                   description:(NSString *)pinDescription
                      progress:(PDKPinUploadProgress)progressBlock
                   withSuccess:(PDKClientSuccess)successBlock
                    andFailure:(PDKClientFailure)failureBlock;
    

    Here is the Pintrest IOS SDK link pinterest/ios-pdk

    1: https://github.com/pinterest/ios-pdk

    The PinterestSDK for iOS will allow you to authenticate an account with Pinterest and make requests on behalf of the authenticated user. For details on the supported endpoint,visit the Pinterest API.