iOS微信分享开发

m文件 
-(void)rightButtonClick:(UIButton *)aButton
{
    UIActionSheet *actionSheet = [[UIActionSheet alloc]
                                  initWithTitle:nil
                                  delegate:self
                                  cancelButtonTitle:@"取消"
                                  destructiveButtonTitle:nil
                                  otherButtonTitles:@"分享到微信", @"分享到朋友圈",nil];
    actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic;
    [actionSheet showInView:self.view];
//  //  [actionSheet showInView:[[[[UIApplication sharedApplication] keyWindow] subviews] lastObject]];
}
#pragma mark ---actionsheet delegate
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0)
    {
        _scene = WXSceneSession;
        [_delegate changeScene:WXSceneSession];
        [self sendAppExtendContent];
    }
    else if (buttonIndex == 1)
    {
        _scene=WXSceneTimeline;
        [_delegate changeScene:WXSceneTimeline];
        [self sendAppExtendContent_friend];
    }
    else if(buttonIndex == 2)
    {
        
    }
}
- (void)actionSheetCancel:(UIActionSheet *)actionSheet
{
    
}
- (void)sendAppExtendContent
{
    if ([WXApi isWXAppInstalled] && [WXApi isWXAppSupportApi])
    {

        WXMediaMessage *message = [WXMediaMessage message];
        [message setThumbImage:[UIImage imageNamed:@"wxIcon.png"]];
        message.title = [NSString stringWithFormat:@"大才校园招聘"];
        message.description = [NSString stringWithFormat:@"%@",[[self.dic valueForKey:@"HiringInfo"] valueForKey:@"Description"]];
        
        WXAppExtendObject *ext1 =[WXAppExtendObject object];
        ext1.url=@"https://itunes.apple.com/us/app/dian-mei-dian/id830075611?ls=1&mt=8";
        
        message.mediaObject=ext1;
        
        SendMessageToWXReq* req = [[SendMessageToWXReq alloc] init];
        req.bText = NO;
        req.message = message;
        req.scene = _scene;
        NSLog(@"=====%d",req.scene);
        
        [WXApi sendReq:req];
    }
    else
    {
        [[iToast makeText:@"你还没有安装微信,无法使用此功能。"] show];
    }
}
-(void)onResp:(BaseResp *)resp
{
    NSLog(@"%@",resp);
    NSLog(@"errStr %@",[resp errStr]);
    NSLog(@"errCode %d",[resp errCode]);
    NSLog(@"type %d",[resp type]);
}
- (void)sendAppExtendContent_friend
{
    if ([WXApi isWXAppInstalled] && [WXApi isWXAppSupportApi])
    {
        WXMediaMessage *message = [WXMediaMessage message];
        message.title = @"大才校园招聘";
        message.description = [NSString stringWithFormat:@"%@",[[self.dic valueForKey:@"HiringInfo"] valueForKey:@"Description"]];;
        [message setThumbImage:[UIImage imageNamed:@"wxIcon.png"]];
        
        WXAppExtendObject *ext =[WXAppExtendObject object];
        ext.url=@"https://itunes.apple.com/us/app/dian-mei-dian/id830075611?ls=1&mt=8";
        message.mediaObject=ext;
        
        SendMessageToWXReq* req = [[SendMessageToWXReq alloc] init];
        req.bText = NO;
        req.message = message;
        req.scene = _scene;
        
        [WXApi sendReq:req];
    }
    else
    {
        [[iToast makeText:@"你还没有安装微信,无法使用此功能。"] show];
    }
}
-(void)changeScene:(NSInteger)scene
{
    _scene = scene;
}

h文件 
#import "YbaseViewController.h"
#import "WXApi.h"
#import "WXApiObject.h"

@protocol sendMsgToWeChatViewDelegate <NSObject>
- (void) sendAppExtendContent;
- (void) changeScene:(NSInteger)scene;
@end

@interface JobDetailViewController : YbaseViewController<UIActionSheetDelegate,WXApiDelegate,sendMsgToWeChatViewDelegate>
{
  enum WXScene _scene;
}
@property (nonatomic,strong) NSString * offerId;
@property (nonatomic, assign) id<sendMsgToWeChatViewDelegate> delegate;
@end

配置完全正确,但是就是不能启动微信客户端。 
后来仔细看官网文档,才发现,发送的带图片的信息不能大于 10k 。操,压缩了图片,总算搞好了。 
你中枪了吗,如果中枪的话,留个言吧 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值