酷店

ALBBSDK.h 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // AlibabaAuthSDK.h
  3. // AlibabaAuthSDK
  4. //
  5. // Created by Bangzhe Liu on 6/15/16.
  6. // Copyright © 2016 taobao. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import <Foundation/Foundation.h>
  10. #import "ALBBSession.h"
  11. #ifndef ALBBNotificationUserLoggedIn
  12. #define ALBBNotificationUserLoggedIn @"ALBB_NOTIFICATION_USER_LOGGED_IN"
  13. #endif
  14. #ifndef ALBBNotificationUserLoggedOut
  15. #define ALBBNotificationUserLoggedOut @"ALBB_NOTIFICATION_USER_LOGGED_OUT"
  16. #endif
  17. #ifndef ALBBNotificationUserGiveUpLogin
  18. #define ALBBNotificationUserGiveUpLogin @"ALBB_NOTIFICATION_USER_GIVE_UP_LOGIN"
  19. #endif
  20. #ifndef ALBBNotificationH5LoginDismiss
  21. #define ALBBNotificationH5LoginDismiss @"ALBB_NOTIFICATION_H5_LOGIN_DISMISS"
  22. #endif
  23. #define ALBB_SDK_VERSION @"1.1.0.25"
  24. /** 回调定义 */
  25. typedef void (^loginSuccessCallback)(ALBBSession *session);
  26. typedef void (^loginFailureCallback)(ALBBSession *session,NSError *error);
  27. typedef void (^loginResultHandler)(ALBBSession *session);
  28. /*
  29. * 授权标记
  30. */
  31. typedef enum {
  32. H5Only = 1 ,//只拉起h5授权
  33. NormalAuth ,//正常授权(淘宝+h5)
  34. } AuthOption;
  35. @interface ALBBSDK : NSObject
  36. + (ALBBSDK *)sharedInstance;
  37. //必须在主线程调用
  38. - (void)ALBBSDKInit;
  39. - (void)auth:(UIViewController *)parentController
  40. successCallback:(loginSuccessCallback) onSuccess
  41. failureCallback:(loginFailureCallback) onFailure;
  42. /**
  43. 设置总的登录成功失败回调
  44. @param handler 登录结果的处理handler,可以通过TaeSession isLogin判断当前登录态
  45. */
  46. - (void)setLoginResultHandler:(void (^)(ALBBSession *session))loginResultHandler;
  47. /**
  48. 退出登录
  49. */
  50. - (void)logout;
  51. /**
  52. 是否是登录URL
  53. */
  54. - (BOOL)isLoginURL:(NSString *)url;
  55. /**
  56. 是否是登出URL
  57. */
  58. - (BOOL)isLogoutUrl:(NSString *)url;
  59. /**
  60. 是否是手淘跳回url
  61. */
  62. - (BOOL)isTBBackUrl:(NSString *)url;
  63. /**
  64. 手淘跳转回来,拿到url调用
  65. @return (BOOL) 调用是否成功
  66. */
  67. - (void)loginByURL:(NSURL *)url;
  68. //如果是接入的极简版本需要手动设置appkey
  69. - (void)setAppkey : (NSString *)appKey;
  70. - (void)openDebugLog;
  71. - (void)setUUID:(NSString *)uuid;
  72. //种本地cookie,初始化已经自动种过,目前供微博使用,微博有清除cookie逻辑,之后需要把登录cookie种回来
  73. - (void)loadCookies;
  74. - (void)setAuthOption:(AuthOption)authOption;
  75. @end