LCApplication

Objective-C

@interface LCApplication : NSObject

// MARK: ID, Key and Server URL

/// Setup ID, Key and Server URL of the application.
/// @param applicationId The applicaiton id for your LeanCloud application.
/// @param clientKey The client key for your LeanCloud application.
/// @param serverURLString The server url for your LeanCloud application.
+ (void)setApplicationId:(nonnull NSString *)applicationId
               clientKey:(nonnull NSString *)clientKey
         serverURLString:(nonnull NSString *)serverURLString;

/*!
 Sets the applicationId and clientKey of your application.
 @param applicationId The applicaiton id for your LeanCloud application.
 @param clientKey The client key for your LeanCloud application.
 */
+ (void)setApplicationId:(nonnull NSString *)applicationId
               clientKey:(nonnull NSString *)clientKey;

/**
 *  get Application Id
 *
 *  @return Application Id
 */
+ (NSString *)getApplicationId;

/**
 *  get Client Key
 *
 *  @return Client Key
 */
+ (NSString *)getClientKey;

/**
 Custom server URL for specific service module.
 
 @param URLString     The URL string of service module.
 @param serviceModule The service module which you want to customize.
 */
+ (void)setServerURLString:(nullable NSString *)URLString
          forServiceModule:(LCServiceModule)serviceModule;

// MARK: Last Modify

+ (void)setLastModifyEnabled:(BOOL)enabled;
+ (BOOL)getLastModifyEnabled;
+ (void)clearLastModifyCache;

// MARK: HTTP Request Timeout Interval

/**
 *  Get the timeout interval for network requests. Default is 60 seconds.
 *
 *  @return timeout interval
 */
+ (NSTimeInterval)networkTimeoutInterval;

/**
 *  Set the timeout interval for network request.
 *
 *  @param time  timeout interval(seconds)
 */
+ (void)setNetworkTimeoutInterval:(NSTimeInterval)time;

// MARK: Log

/*!
 * Enable logs of all levels and domains. When define DEBUG macro, it's enabled, otherwise, it's not enabled. This is recommended. But you can set it NO, and call LCLogger's methods to control which domains' log should be output.
 */
+ (void)setAllLogsEnabled:(BOOL)enabled;

/// Set log level.
/// @param level The level of log.
+ (void)setLogLevel:(LCLogLevel)level;

/// Get log level.
+ (LCLogLevel)logLevel;

// MARK: Schedule work

/**
 *  get the query cache expired days
 *
 *  @return the query cache expired days
 */
+ (NSInteger)queryCacheExpiredDays;

/**
 *  set Query Cache Expired Days, default is 30 days
 *
 *  @param days the days you want to set
 */
+ (void)setQueryCacheExpiredDays:(NSInteger)days;

/**
 *  get the file cache expired days
 *
 *  @return the file cache expired days
 */
+ (NSInteger)fileCacheExpiredDays;

/**
 *  set File Cache Expired Days, default is 30 days
 *
 *  @param days the days you want to set
 */
+ (void)setFileCacheExpiredDays:(NSInteger)days;

// MARK: SMS

+ (void)verifySmsCode:(NSString *)code
    mobilePhoneNumber:(NSString *)phoneNumber
             callback:(LCBooleanResultBlock)callback;

// MARK: Date

/// Get current server date synchronously.
/// @param error Pointer to `NSError *`.
+ (nullable NSDate *)getServerDate:(NSError **)error;

/// Get current server date synchronously.
/// @param error Pointer to `NSError *`.
+ (nullable NSDate *)getServerDateAndThrowsWithError:(NSError **)error;

/// Get current server date asynchronously.
/// @param block Result callback.
+ (void)getServerDateWithBlock:(void (^)(NSDate * _Nullable date, NSError * _Nullable error))block;

// MARK: Misc

+ (instancetype)defaultApplication;

+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;

@property (nonatomic, readonly) NSString *identifier;
@property (nonatomic, readonly) NSString *key;
@property (nonatomic, readonly, nullable) NSString *serverURLString;
@property (nonatomic, copy, nullable) NSString *RTMServer;

- (void)setWithIdentifier:(NSString *)identifier key:(NSString *)key;

@end

Swift

class LCApplication : NSObject

Undocumented

  • Setup ID, Key and Server URL of the application.

    Declaration

    Objective-C

    + (void)setApplicationId:(nonnull NSString *)applicationId
                   clientKey:(nonnull NSString *)clientKey
             serverURLString:(nonnull NSString *)serverURLString;

    Swift

    class func setApplicationId(_ applicationId: String, clientKey: String, serverURLString: String)

    Parameters

    applicationId

    The applicaiton id for your LeanCloud application.

    clientKey

    The client key for your LeanCloud application.

    serverURLString

    The server url for your LeanCloud application.

  • Undocumented

    Declaration

    Objective-C

    + (void)setApplicationId:(nonnull NSString *)applicationId
                   clientKey:(nonnull NSString *)clientKey;

    Swift

    class func setApplicationId(_ applicationId: String, clientKey: String)
  • get Application Id

    Declaration

    Objective-C

    + (nonnull NSString *)getApplicationId;

    Swift

    class func getId() -> String

    Return Value

    Application Id

  • get Client Key

    Declaration

    Objective-C

    + (nonnull NSString *)getClientKey;

    Swift

    class func getClientKey() -> String

    Return Value

    Client Key

  • Custom server URL for specific service module.

    Declaration

    Objective-C

    + (void)setServerURLString:(nullable NSString *)URLString
              forServiceModule:(LCServiceModule)serviceModule;

    Swift

    class func setServerURLString(_ URLString: String?, for serviceModule: LCServiceModule)

    Parameters

    URLString

    The URL string of service module.

    serviceModule

    The service module which you want to customize.

  • Undocumented

    Declaration

    Objective-C

    + (void)setLastModifyEnabled:(BOOL)enabled;

    Swift

    class func setLastModifyEnabled(_ enabled: Bool)
  • Undocumented

    Declaration

    Objective-C

    + (BOOL)getLastModifyEnabled;

    Swift

    class func getLastModifyEnabled() -> Bool
  • Undocumented

    Declaration

    Objective-C

    + (void)clearLastModifyCache;

    Swift

    class func clearLastModifyCache()
  • Get the timeout interval for network requests. Default is 60 seconds.

    Declaration

    Objective-C

    + (NSTimeInterval)networkTimeoutInterval;

    Swift

    class func networkTimeoutInterval() -> TimeInterval

    Return Value

    timeout interval

  • Set the timeout interval for network request.

    Declaration

    Objective-C

    + (void)setNetworkTimeoutInterval:(NSTimeInterval)time;

    Swift

    class func setNetworkTimeoutInterval(_ time: TimeInterval)

    Parameters

    time

    timeout interval(seconds)

  • Undocumented

    Declaration

    Objective-C

    + (void)setAllLogsEnabled:(BOOL)enabled;

    Swift

    class func setAllLogsEnabled(_ enabled: Bool)
  • Set log level.

    Declaration

    Objective-C

    + (void)setLogLevel:(LCLogLevel)level;

    Swift

    class func setLogLevel(_ level: LCLogLevel)

    Parameters

    level

    The level of log.

  • Get log level.

    Declaration

    Objective-C

    + (LCLogLevel)logLevel;

    Swift

    class func logLevel() -> LCLogLevel
  • get the query cache expired days

    Declaration

    Objective-C

    + (NSInteger)queryCacheExpiredDays;

    Swift

    class func queryCacheExpiredDays() -> Int

    Return Value

    the query cache expired days

  • set Query Cache Expired Days, default is 30 days

    Declaration

    Objective-C

    + (void)setQueryCacheExpiredDays:(NSInteger)days;

    Swift

    class func setQueryCacheExpiredDays(_ days: Int)

    Parameters

    days

    the days you want to set

  • get the file cache expired days

    Declaration

    Objective-C

    + (NSInteger)fileCacheExpiredDays;

    Swift

    class func fileCacheExpiredDays() -> Int

    Return Value

    the file cache expired days

  • set File Cache Expired Days, default is 30 days

    Declaration

    Objective-C

    + (void)setFileCacheExpiredDays:(NSInteger)days;

    Swift

    class func setFileCacheExpiredDays(_ days: Int)

    Parameters

    days

    the days you want to set

  • Undocumented

    Declaration

    Objective-C

    + (void)verifySmsCode:(NSString *)code
        mobilePhoneNumber:(NSString *)phoneNumber
                 callback:(LCBooleanResultBlock)callback;

    Swift

    class func verifySmsCode(_ code: String, mobilePhoneNumber phoneNumber: String, callback: @escaping LCBooleanResultBlock)
  • Get current server date synchronously.

    Declaration

    Objective-C

    + (nullable NSDate *)getServerDate:(NSError *_Nullable *_Nullable)error;

    Swift

    class func getServerDate() throws -> Date

    Parameters

    error

    Pointer to NSError *.

  • Get current server date synchronously.

    Declaration

    Objective-C

    + (nullable NSDate *)getServerDateAndThrowsWithError:
        (NSError *_Nullable *_Nullable)error;

    Swift

    class func getServerDateAndThrows() throws -> Date

    Parameters

    error

    Pointer to NSError *.

  • Get current server date asynchronously.

    Declaration

    Objective-C

    + (void)getServerDateWithBlock:(nonnull void (^)(NSDate *_Nullable,
                                                     NSError *_Nullable))block;

    Swift

    class func getServerDate(_ block: @escaping (Date?, Error?) -> Void)

    Parameters

    block

    Result callback.

  • Undocumented

    Declaration

    Objective-C

    + (instancetype)defaultApplication;

    Swift

    class func `default`() -> Self
  • Unavailable

    Undocumented

    Declaration

    Objective-C

    + (instancetype)new NS_UNAVAILABLE;
  • Unavailable

    Undocumented

    Declaration

    Objective-C

    - (instancetype)init NS_UNAVAILABLE;
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSString *identifier

    Swift

    var identifier: String { get }
  • key

    Undocumented

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSString *key

    Swift

    var key: String { get }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSString *serverURLString

    Swift

    var serverURLString: String? { get }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSString *RTMServer

    Swift

    var rtmServer: String? { get set }
  • Undocumented

    Declaration

    Objective-C

    - (void)setWithIdentifier:(NSString *)identifier key:(NSString *)key;

    Swift

    func setWithIdentifier(_ identifier: String, key: String)