//
//  OffcnPushSDKiOS.h
//  OffcnIMSDKiOS
//
//  Created by jie 张 on 2022/4/13.
//  Copyright © 2022 offcn. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

//SDK版本号
#define OFFCNPUSHSDKIOS_VERSION @"1.0.0.0"

//监听Push消息通知
#define kOffcnPushSDKiOSRevMsgNotification @"kOffcnPushSDKiOSRevMsgNotification"
//监听Push长链接状态通知
#define kOffcnPushSDKiOSConnectStateNotification @"kOffcnPushSDKiOSConnectStateNotification"

typedef NS_ENUM(NSUInteger, OffcnPushConnectStatus) {
    OffcnPushConnectStatusMissingParameter = 201019,  //缺少参数
    OffcnPushConnectStatusInitializing = 201029,  //连接初始化中
    OffcnPushConnectStatusInitializingFail = 201030,  //连接初始化失败
    
    OffcnPushConnectStatusSuccess = 0,        //连接成功
    OffcnPushConnectStatusFail = 1,           //连接失败
    OffcnPushConnectStatusBreak = 2,          //连接断开
    OffcnPushConnectStatusDisConnectOK = 3,   //手动断开成功
    
    OffcnPushConnectStatusReconnect_start = 4,   //开始重连
    OffcnPushConnectStatusReconnect_success = 5, //重连成功
    OffcnPushConnectStatusReconnect_fail = 6,    //重连失败
    
    OffcnPushConnectStatusOverLimit = 3001,        //连接数量超过限制
    OffcnPushConnectStatusUserNoExist = 5002,        //用户不存在
    OffcnPushConnectStatusTokenInvalid = 5003,        //token已失效
    OffcnPushConnectStatusKickout = 8002,        //账号被踢
};

@interface OffcnPushSDKConnectStateModel : NSObject

@property (nonatomic, assign) OffcnPushConnectStatus pushConnectStatus;//连接状态
@property (nonatomic, copy) NSString *message;
@end



@interface OffcnPushSDKiOS : NSObject

@property (nonatomic, assign) OffcnPushConnectStatus pushConnectStatus;//连接状态

//单例
+(OffcnPushSDKiOS *)defaultService;

/// Push SDK初始化并开始通道连接
/// @param isTest 是否选用测试环境
/// @param appkey 创建APP时获取的appkey
/// @param appsecret 创建APP时获取的appsecret
-(void)setupPushWithIsTest:(BOOL)isTest appkey:(NSString *)appkey appsecret:(NSString *)appsecret;


/// 注册该设备的deviceToken
/// @param deviceToken 设备deviceToken
/// @param finished 结果回调
-(void)registerWithDeviceToken:(NSData *)deviceToken finished:(void(^)(BOOL success,id response,NSString *errorMessage))finished;


/// 注销该设备的deviceToken
/// @param finished 结果回调
-(void)unRegisterDeviceTokenFinished:(void(^)(BOOL success,id response,NSString *errorMessage))finished;


/// 绑定账号
/// @param accid 用户账号id
/// @param finished 结果回调
-(void)bindWithAccid:(NSString *)accid finished:(void(^)(BOOL success,id response,NSString *errorMessage))finished;


/// 解绑账号
/// @param accid 用户账号id
/// @param finished 结果回调
-(void)unbindWithAccid:(NSString *)accid finished:(void(^)(BOOL success,id response,NSString *errorMessage))finished;


/// 向设备添加自定义标签
/// @param tags 标签名
/// @param finished 结果回调
-(void)bindWithTags:(NSArray *)tags
       finished:(void(^)(BOOL success,id response,NSString *errorMessage))finished;


/// 删除设备的自定义标签
/// @param tags 标签名
/// @param finished 结果回调
-(void)unbindWithTags:(NSArray *)tags
         finished:(void(^)(BOOL success,id response,NSString *errorMessage))finished;


/// 向设备添加自定义别名
/// @param alias 别名
/// @param finished 结果回调
-(void)bindWithAlias:(NSArray *)alias
       finished:(void(^)(BOOL success,id response,NSString *errorMessage))finished;


/// 删除设备的自定义别名
/// @param alias 别名
/// @param finished 结果回调
-(void)unbindWithAlias:(NSArray *)alias
         finished:(void(^)(BOOL success,id response,NSString *errorMessage))finished;




/// 获取APNs返回的deviceToken
-(NSString *)getApnsDeviceToken;


/// 获取本机的deviceId
-(NSString *)getDeviceId;


/// 返回SDK版本
-(NSString *)getVersion;


//主动断开连接，不会重连
-(void)disConnectPushServerForever;

//重新连接
-(void)reconnectionPushServerForever;
@end

NS_ASSUME_NONNULL_END
