Skip to content

guideline upgrade from 11 to 12

pzheng edited this page Jun 29, 2020 · 1 revision

guideline-upgrade-from-11-to-12

API-breaking-changes

setup

  • 11.X.X

    // 配置 SDK 储存
    [AVOSCloud setServerURLString:@"https://xxx.example.com" forServiceModule:AVServiceModuleAPI];
    // 配置 SDK 推送
    [AVOSCloud setServerURLString:@"https://xxx.example.com" forServiceModule:AVServiceModulePush];
    // 配置 SDK 云引擎(用于访问云函数,使用 API 自定义域名,而非云引擎自定义域名)
    [AVOSCloud setServerURLString:@"https://xxx.example.com" forServiceModule:AVServiceModuleEngine];
    // 配置 SDK 即时通讯
    [AVOSCloud setServerURLString:@"https://xxx.example.com" forServiceModule:AVServiceModuleRTM];
    // 配置 SDK 统计
    [AVOSCloud setServerURLString:@"https://xxx.example.com" forServiceModule:AVServiceModuleStatistics];
    // 初始化应用
    [AVOSCloud setApplicationId:@"{{appid}}" clientKey:@"{{appkey}}"];
  • 12.X.X

    [AVOSCloud setApplicationId:{{appid}}
                      clientKey:{{appkey}}
                serverURLString:"https://please-replace-with-your-customized.domain.com"];

installation

  • 11.X.X

    [[AVInstallation defaultInstallation] setDeviceTokenFromData:deviceToken];
  • 12.X.X

    [[AVInstallation defaultInstallation] setDeviceTokenFromData:deviceToken
                                                          teamId:@"YOUR_APNS_TEAM_ID"];

IM

AVIMClientDelegate

  • 11.X.X

    /// Deprecated, use `-[AVIMClientDelegate imClientPaused:error:]` instead.
    - (void)imClientPaused:(AVIMClient *)imClient;
    
    /// Deprecated, use `-[AVIMClientDelegate imClientClosed:error:]` instead.
    - (void)client:(AVIMClient *)client didOfflineWithError:(NSError * _Nullable)error
  • 12.2.X

    /// Client paused, means the connection lost.
    ///
    /// Common Scenario:
    ///     * Network unreachable or interface changed.
    ///     * App enter background
    ///     * ...
    ///
    /// @param imClient The client.
    /// @param error The reason for pause.
    - (void)imClientPaused:(AVIMClient *)imClient error:(NSError * _Nullable)error;
    
    /// Client closed and will not try recover connection automatically.
    ///
    /// Common Scenario:
    ///     * code: `4111`, reason: `SESSION_CONFLICT`
    ///     * code: `4115`, reason: `KICKED_BY_APP`
    ///
    /// @param imClient The client.
    /// @param error The reason for close.
    - (void)imClientClosed:(AVIMClient *)imClient error:(NSError * _Nullable)error;

AVIMClient

  • 11.X.X

    /// NOT Exist
    - (instancetype)initWithClientId:(NSString *)clientId;
    
    /// NOT Exist
    - (instancetype)initWithClientId:(NSString *)clientId tag:(NSString * _Nullable)tag;
    
    /// NOT Exist
    - (instancetype)initWithUser:(AVUser *)user;
    
    /// NOT Exist
    - (instancetype)initWithUser:(AVUser *)user tag:(NSString * _Nullable)tag;
  • 12.2.X

    /// NOT Recommend
    - (nullable instancetype)initWithClientId:(NSString *)clientId;
    
    /// Recommend
    - (nullable instancetype)initWithClientId:(NSString *)clientId
                                        error:(NSError * __autoreleasing *)error;
    
    /// NOT Recommend
    - (nullable instancetype)initWithClientId:(NSString *)clientId
                                          tag:(NSString * _Nullable)tag;
    
    /// Recommend
    - (nullable instancetype)initWithClientId:(NSString *)clientId
                                          tag:(NSString * _Nullable)tag
                                        error:(NSError * __autoreleasing *)error;
    
    /// NOT Recommend
    - (nullable instancetype)initWithUser:(AVUser *)user;
    
    /// Recommend
    - (nullable instancetype)initWithUser:(AVUser *)user
                                    error:(NSError * __autoreleasing *)error;
    
    /// NOT Recommend
    - (nullable instancetype)initWithUser:(AVUser *)user
                                      tag:(NSString * _Nullable)tag;
    
    /// Recommend
    - (nullable instancetype)initWithUser:(AVUser *)user
                                      tag:(NSString * _Nullable)tag
                                    error:(NSError * __autoreleasing *)error;

behavior-breaking-changes

单设备登陆(client 被动登出)

  • 11.X.X

    - (void)client:(AVIMClient *)client didOfflineWithError:(NSError * _Nullable)error
    {
        if ([error.domain isEqualToString:kLeanCloudErrorDomain] &&
            error.code == 4111) {
            /// SESSION_CONFLICT
        }
    }
  • 12.2.X

    /// opening operation
    [client openWithOption:AVIMClientOpenOptionReopen callback:^(BOOL succeeded, NSError * _Nullable error) {
        if ([error.domain isEqualToString:kLeanCloudErrorDomain] &&
            error.code == 4111) {
            /// SESSION_CONFLICT
        }
    }];
    
    /// opened
    - (void)imClientClosed:(AVIMClient *)imClient error:(NSError * _Nullable)error
    {
        if ([error.domain isEqualToString:kLeanCloudErrorDomain] &&
            error.code == 4111) {
            /// SESSION_CONFLICT
        }
    }