Нет описания

ALBBSDK.h 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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.32"
  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. * 退出登录
  53. * @param callback 登出回调
  54. */
  55. - (void)logoutWithCallback:(void(^)())callback;
  56. /**
  57. 是否是登录URL
  58. */
  59. - (BOOL)isLoginURL:(NSString *)url;
  60. /**
  61. 是否是登出URL
  62. */
  63. - (BOOL)isLogoutUrl:(NSString *)url;
  64. /**
  65. 是否是手淘跳回url
  66. */
  67. - (BOOL)isTBBackUrl:(NSString *)url;
  68. /**
  69. 手淘跳转回来,拿到url调用
  70. @return (BOOL) 调用是否成功
  71. */
  72. - (void)loginByURL:(NSURL *)url;
  73. //如果是接入的极简版本需要手动设置appkey
  74. - (void)setAppkey : (NSString *)appKey;
  75. - (void)openDebugLog;
  76. - (void)setUUID:(NSString *)uuid;
  77. //种本地cookie,初始化已经自动种过,目前供微博使用,微博有清除cookie逻辑,之后需要把登录cookie种回来
  78. - (void)loadCookies;
  79. - (void)setAuthOption:(AuthOption)authOption;
  80. @end