WechatAuthSDK.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // WechatAuthSDK.h
  3. // WechatAuthSDK
  4. //
  5. // Created by 李凯 on 13-11-29.
  6. // Copyright (c) 2013年 Tencent. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. enum AuthErrCode {
  11. WechatAuth_Err_Ok = 0, //Auth成功
  12. WechatAuth_Err_NormalErr = -1, //普通错误
  13. WechatAuth_Err_NetworkErr = -2, //网络错误
  14. WechatAuth_Err_GetQrcodeFailed = -3, //获取二维码失败
  15. WechatAuth_Err_Cancel = -4, //用户取消授权
  16. WechatAuth_Err_Timeout = -5, //超时
  17. };
  18. @protocol WechatAuthAPIDelegate<NSObject>
  19. @optional
  20. - (void)onAuthGotQrcode:(UIImage *)image; //得到二维码
  21. - (void)onQrcodeScanned; //二维码被扫描
  22. - (void)onAuthFinish:(int)errCode AuthCode:(NSString *)authCode; //成功登录
  23. @end
  24. @interface WechatAuthSDK : NSObject{
  25. NSString *_sdkVersion;
  26. __weak id<WechatAuthAPIDelegate> _delegate;
  27. }
  28. @property(nonatomic, weak) id<WechatAuthAPIDelegate> delegate;
  29. @property(nonatomic, readonly) NSString *sdkVersion; //authSDK版本号
  30. /*! @brief 发送登录请求,等待WechatAuthAPIDelegate回调
  31. *
  32. * @param appId 微信开发者ID
  33. * @param nonceStr 一个随机的尽量不重复的字符串,用来使得每次的signature不同
  34. * @param timeStamp 时间戳
  35. * @param scope 应用授权作用域,拥有多个作用域用逗号(,)分隔
  36. * @param signature 签名
  37. * @param schemeData 会在扫码后拼在scheme后
  38. * @return 成功返回YES,失败返回NO
  39. 注:该实现只保证同时只有一个Auth在运行,Auth未完成或未Stop再次调用Auth接口时会返回NO。
  40. */
  41. - (BOOL)Auth:(NSString *)appId
  42. nonceStr:(NSString *)nonceStr
  43. timeStamp:(NSString*)timeStamp
  44. scope:(NSString *)scope
  45. signature:(NSString *)signature
  46. schemeData:(NSString *)schemeData;
  47. /*! @brief 暂停登录请求
  48. *
  49. * @return 成功返回YES,失败返回NO。
  50. */
  51. - (BOOL)StopAuth;
  52. @end