ShareSDK第三方平台使用指南:Pinterest

本篇文档主要讲解如何使用Pinterest平台进行分享(不支持授权)

创建应用

1.登录Pinterest开发者平台并通过企业认证

2.点击接受Pinterest的开发者服务条款

2.单击连接应用程序

4.编辑应用信息

以下为创建过程示例,图中信息仅为示例,创建时请按照真实信息填写,否则无法正常使用

image.png

填写基本信息

image.png

集成使用

配置信息获取

客户端在使用Pinterest平台之前,需要先获取Pinterest开发者平台的应用程序 id

image.png

Android

SDK集成

在集成Pinterest相关能力之前,请先按照ShareSDK集成指南完成ShareSDK的集成。

在对应gradle文件中,添加如下Pinterest代码,其中appId的值对应Pinterest平台中的应用程序 id

ShareSDK {
    devInfo {
        Pinterest {
            appId "xxxxxxx"
            shareByAppClient  true
            enable true
        }
    }
}

分享示例

代码

以下代码示例分享图文到Pinterest,Pinterest必须用客户端才可分享,调用的系统客户端分享,所以无法获取准确回调,点击调用Pinterest分享,默认执行onComplete回调。

Platform platform = ShareSDK.getPlatform(Pinterest.NAME);
Platform.ShareParams shareParams = new  Platform.ShareParams();
shareParams.setText("Pinterest分享"); 
shareParams.setImageUrl("https://download.sdk.mob.com/web/images/2019/07/30/14/1564468183056/750_750_65.12.png");
shareParams.setUrl("https://www.mob.com/");
// 设置分享事件回调(注:回调放在不能保证在主线程调用,不可以在里面直接处理UI操作)
platform.setPlatformActionListener(new PlatformActionListener() {
      @Override
      public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
              //分享成功
      }
      @Override
      public void onError(Platform platform, int i, Throwable throwable) {
           //分享失败
      }
      @Override
      public void onCancel(Platform platform, int i) {
           //分享取消
      }
});
platform.share(shareParams);
效果图

iOS

SDK集成

集成SDK

在集成Pinterest相关能力之前,请先按照ShareSDK集成指南完成ShareSDK的集成

添加白名单

在项目的info.plist中添加Queried URL Schemes,类型为Array,然后添加一个需要支持的项目,类型为字符串类型,添加:pinit,pinterestsdk.v1

960be36a88ec0e7eb18a1ea3a4c57aa6.JPG

配置scheme

打开项目的Info选项,添加对应平台的URL Scheme配置,配置为pdk+ClientId,如下图:

727c4eaf455e90cc4cefc8f4e52b68c3.JPG

初始化平台
[ShareSDK registPlatforms:^(SSDKRegister *platformsRegister) {
   [platformsRegister setupPinterestByClientId:@"XXXXXXXX"];
}];

分享示例

代码
#import <ShareSDK/ShareSDK.h>
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
[parameters SSDKSetupShareParamsByText:nil
                                    images:@"http://download.sdk.mob.com/web/images/2019/07/30/14/1564468183056/750_750_65.12.png"
                                       url:nil
                                     title:nil
                                      type:SSDKContentTypeImage];
[ShareSDK share:SSDKPlatformTypePinterest parameters:parameters onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
        if (state == SSDKResponseStateSuccess)
              {
                  NSLog(@"分享成功");
              }
              if (state == SSDKResponseStateFail)
              {
                  NSLog(@"失败----%@",error.description);
              }
              if (state == SSDKResponseStateCancel)
              {
                  NSLog(@"取消");
              }
}];
效果图

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MobTech袤博科技

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值