iOS微信分享檢測

import "AppDelegate.h"

- (void)onResp:(BaseResp *)resp
{
    
    /*
     WXSuccess           = 0,   成功
     WXErrCodeCommon     = -1,   普通錯誤類型
     WXErrCodeUserCancel = -2,   用戶點擊取消并返回
     WXErrCodeSentFail   = -3,    發送失敗
     WXErrCodeAuthDeny   = -4,   授權失敗
     WXErrCodeUnsupport  = -5,    微信不支持
     */
    NSString * strMsg = [NSString stringWithFormat:@"errorCode: %d",resp.errCode];
    NSLog(@"strMsg: %@",strMsg);
    
    NSString * errStr       = [NSString stringWithFormat:@"errStr: %@",resp.errStr];
    NSLog(@"errStr: %@",errStr);
    
    
    NSString * strTitle;
    //判斷是微信消息的回調 --> 是支付回調回來的還是消息回調回來的.
    if ([resp isKindOfClass:[SendMessageToWXResp class]])
    {
        
        // 判斷errCode 進行回調處理
        if (resp.errCode == 0)
        {
            strTitle = [NSString stringWithFormat:@"分享成功"];
        }
    }
    
//發出通知 從微信回調回來之后,發一個通知,讓請求支付的頁面接收消息,并且展示出來,或者進行一些自定義的展示或者跳轉
    NSNotification * notification = [NSNotification notificationWithName:@"WXShare" object:@(resp.errCode)];
    [[NSNotificationCenter defaultCenter] postNotification:notification];
}

文件中

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getOrderPayResult:) name:@"WXShare" object:nil];

- (void)getOrderPayResult:(NSNotification *)notification
{}
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容