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 。操,压缩了图片,总算搞好了。

你中枪了吗,如果中枪的话,留个言吧

ios微信分享---按照官方文档上配置缺不能正常启动微信客户端,布布扣,bubuko.com

ios微信分享---按照官方文档上配置缺不能正常启动微信客户端

上一篇:微信小程序使用wx.request发送multipart/form-data请求的方法


下一篇:微信公众平台开发接口PHP SDK完整版