TUILogin.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. // Created by Tencent on 2023/06/09.
  2. // Copyright © 2023 Tencent. All rights reserved.
  3. /**
  4. * TUILogin
  5. * This module is mainly responsible for the login logic of IM and TRTC
  6. */
  7. #import <Foundation/Foundation.h>
  8. NS_ASSUME_NONNULL_BEGIN
  9. typedef void (^TFail)(int code, NSString * __nullable msg);
  10. typedef void (^TSucc)(void);
  11. typedef NS_ENUM(NSInteger, TUILogLevel) {
  12. /**
  13. * < Do not output any SDK logs
  14. */
  15. TUI_LOG_NONE = 0,
  16. /**
  17. * < Output logs at the DEBUG, INFO, WARNING, and ERROR levels
  18. */
  19. TUI_LOG_DEBUG = 3,
  20. /**
  21. * < Output logs at the INFO, WARNING, and ERROR levels
  22. */
  23. TUI_LOG_INFO = 4,
  24. /**
  25. * < Output logs at the WARNING and ERROR levels
  26. */
  27. TUI_LOG_WARN = 5,
  28. /**
  29. * < Output logs at the ERROR level
  30. */
  31. TUI_LOG_ERROR = 6,
  32. };
  33. /**
  34. * Status in different kinds of business scene
  35. */
  36. typedef NS_ENUM(NSInteger, TUIBusinessScene) {
  37. None = 0,
  38. InRecording = 1,
  39. InCallingRoom = 2,
  40. InMeetingRoom = 3,
  41. InLivingRoom = 4,
  42. };
  43. /// Enumeration definition of login account type
  44. typedef NS_ENUM(NSInteger, TUILoginAccountType) {
  45. TUI_ACCOUNT_TYPE_UNKOWN = 0, ///< Unkown
  46. TUI_ACCOUNT_TYPE_IM = 1, ///< IM
  47. TUI_ACCOUNT_TYPE_PUSH = 2, ///< Push
  48. };
  49. /**
  50. * Notification for init im sdk succeed
  51. */
  52. FOUNDATION_EXTERN NSString *const TUIInitSdkSuccessNotification;
  53. /**
  54. * Notification for init im sdk failed
  55. */
  56. FOUNDATION_EXTERN NSString *const TUIInitSdkFailNotification;
  57. /**
  58. * Notification for log-in succeed
  59. */
  60. FOUNDATION_EXTERN NSString *const TUILoginSuccessNotification;
  61. /**
  62. * Notification for log-in failed
  63. */
  64. FOUNDATION_EXTERN NSString *const TUILoginFailNotification;
  65. /**
  66. * Notification for log-out succeed
  67. */
  68. FOUNDATION_EXTERN NSString *const TUILogoutSuccessNotification;
  69. /**
  70. * Notification for log-out failed
  71. */
  72. FOUNDATION_EXTERN NSString *const TUILogoutFailNotification;
  73. @protocol TUILoginListener <NSObject>
  74. /**
  75. * Callback that the SDK is connecting to the server
  76. */
  77. - (void)onConnecting;
  78. /**
  79. * Callback that the SDK has successfully connected to the server
  80. */
  81. - (void)onConnectSuccess;
  82. /**
  83. * Callback for SDK connection to server failure
  84. */
  85. - (void)onConnectFailed:(int)code err:(NSString * __nullable)err;
  86. /**
  87. * The callback of the current user being kicked off, the user can be prompted on the UI at this time, and the login() function of V2TIMManager can be called
  88. * again to log in again.
  89. */
  90. - (void)onKickedOffline;
  91. /**
  92. * The callback of the login credentials expired when online, you need to generate a new userSig and call the login() function of V2TIMManager again to log in
  93. * again.
  94. */
  95. - (void)onUserSigExpired;
  96. @end
  97. @interface TUILoginConfig : NSObject
  98. @property(nonatomic, assign) TUILogLevel logLevel;
  99. @property(nonatomic, copy, nullable) void (^onLog)(NSInteger logLevel, NSString * __nullable logContent);
  100. @property(nonatomic, assign) BOOL initLocalStorageOnly;
  101. @end
  102. @interface TUILogin : NSObject
  103. + (void)initWithSdkAppID:(int)sdkAppID __attribute__((deprecated("use login:userID:userSig:succ:fail:")));
  104. + (void)login:(NSString *)userID
  105. userSig:(NSString *)userSig
  106. succ:(__nullable TSucc)succ
  107. fail:(__nullable TFail)fail __attribute__((deprecated("use login:userID:userSig:succ:fail:")));
  108. + (void)login:(int)sdkAppID
  109. userID:(NSString *)userID
  110. userSig:(NSString *)userSig
  111. succ:(__nullable TSucc)succ
  112. fail:(__nullable TFail)fail;
  113. + (void)login:(int)sdkAppID
  114. userID:(NSString *)userID
  115. userSig:(NSString *)userSig
  116. config:(TUILoginConfig * __nullable)config
  117. succ:(__nullable TSucc)succ
  118. fail:(__nullable TFail)fail;
  119. + (void)logout:(__nullable TSucc)succ
  120. fail:(__nullable TFail)fail;
  121. + (void)addLoginListener:(id<TUILoginListener>)listener;
  122. + (void)removeLoginListener:(id<TUILoginListener>)listener;
  123. + (int)getSdkAppID;
  124. + (BOOL)isUserLogined;
  125. + (NSString * __nullable)getUserID;
  126. + (NSString * __nullable)getUserSig;
  127. + (NSString * __nullable)getNickName;
  128. + (NSString * __nullable)getFaceUrl;
  129. /**
  130. * No-thread-safe
  131. */
  132. + (void)setCurrentBusinessScene:(TUIBusinessScene)scene;
  133. + (TUIBusinessScene)getCurrentBusinessScene;
  134. @end
  135. NS_ASSUME_NONNULL_END