iOS开发大全iOS开发首页投稿(暂停使用,暂停投稿)

iOS 使用微信分享(Objective-C版)

2017-07-28  本文已影响182人  LeeLom

1. 在微信开放平台中创建你应用


首先需要在微信开放平台中注册你的应用,取得微信给你的AppID。在分享的过程中,我们需要使用这个AppID。具体的注册步骤跟着微信的平台一步步走就好。审核的过程大概需要2-3天。审核通过后如下可以看到:

微信审核页面

2. 在你的应用中进行如下的操作


3. 使用封装好的文件到底有多简单!


觉得好用,来个赞好不好...

开个玩笑不要黑我.jpeg
  /**
 * 分享图片
 * image: 需要分享的图片
 * thumbImage: 缩略图
 * type: 0:分享给微信好友;1:分享到朋友圈
 **/
+ (void)shareToWechatWithImage:(UIImage *)image
                    thumbImage:(UIImage *)thumbImage
                          type:(NSUInteger)type;

调用的例子

  // image 和 thumbImage可以不一样
  UIImage *image = [UIImage imageNamed:@"test"];
  UIImage *thumbImage = [UIImage imageNamed:@"test"];
  [BYRWechatShare shareToWechatWithImage:image thumbImage:thumbImage type:0];
tupian.jpeg
  /**
   * 分享音乐
   * title: 音乐标题
   * description: 音乐描述
   * thumbImage: 缩略图
   * musicUrl: 音乐url
   * musicDataUrl: 音乐数据url
   * type: 0:分享给微信好友;1:分享到朋友圈
   **/
  + (void)shareToWechatWithMusicTitle:(NSString *)title
                          description:(NSString *)description
                           thumbImage:(UIImage *)thumbImage
                             musicUrl:(NSString *)musicUrl
                         musicDataUrl:(NSString *)musicDataUrl
                                 type:(NSUInteger)type;

调用的例子

  UIImage *thumbImage = [UIImage imageNamed:@"test"];
  [BYRWechatShare shareToWechatWithMusicTitle:@"歌曲名"
                                  description:@"歌曲描述"
                                   thumbImage:thumbImage
                                     musicUrl:@"www.baidu.com" //替换你的URL
                                 musicDataUrl:@"www.baidu.com" //替换你的URL
                                         type:1];
歌曲.jpeg
  /**
   * 分享网页
   * title: 网页标题
   * description: 网页描述
   * thumbImage: 缩略图
   * webpageUrl: 网页url
   * type: 0:分享给微信好友;1:分享到朋友圈
   **/
  + (void)shareToWechatWithWebTitle:(NSString *)title
                        description:(NSString *)description
                         thumbImage:(UIImage *)thumbImage
                         webpageUrl:(NSString *)webpageUrl
                               type:(NSUInteger)type;
  [BYRWechatShare shareToWechatWithWebTitle:@"网页名字"
                                description:@"网页描述"
                                 thumbImage:thumbImage
                                 webpageUrl:@"www.baidu.com"
                                       type:1];
wangyemingzi.jpeg
上一篇 下一篇

猜你喜欢

热点阅读