IOS SDK #

@interface UPushClient : NSObject

/**
 @brief 配置
 @param appId           项目唯一标示
 @param appKey          应用唯一标示
 @param delegate        事件回调
*/
+ (void) configureUPush:(NSString*) appId appKey:(NSString*)appKey delegate:(id<UPushDelegate>)delegate;

/**
 @brief 注册推送
 @param ip              master地址
 @param port            master端口
 @param options         通知配置
 */
+ (void) registerUPush:(NSString*)ip port:(int)port options:(UPushNotificationOptions)options;

/**
 @brief 注册到指定连接服务
 @param ip              connector地址
 @param port            connector端口
 @param options         通知配置
 */
+ (void) registerSpecifiedUPushServer:(NSString*)ip port:(int)port options:(UPushNotificationOptions)options;

/**
 @brief 注销推送
 */
+ (void) unregisterUPush;

/**
 @brief 绑定用户
 @param userId       用户ID
 */
+ (void) bindUser:(NSString*)userId;

/**
 @brief 取得状态
 @return
 */
+ (NSInteger) getStatus;

/**
 @brief 取得已经绑定的用户ID
 @return
 */
+ (NSString*) getUserId;

/**
 @brief 取得PushToken
 @return
 */
+ (NSString*) getPushToken;

/**
  @brief 检查连接,未连接时会建立连接,登录成功后有效
 */
+ (void) checkConnection;

@end

UPushDelegate #

@protocol UPushDelegate
@required

/**
 @brief 接收消息
 @param msg         消息
 @param pushTime    推送时间
 @param pushType    推送类型
 */
- (void) onPush:(UMessage*) msg pushTime:(int64_t) pushTime pushType:(UPushType) pushType;

/**
 @brief 通知被点击,包括APNS通知
 @param msg      通知栏被点击的消息, 类型为UMessage、NSDictionary
 @param pushType 消息推送类型,用于区分本地推送或者远程推送
 @note 类型为UMessage时表示是upush的通知,为NSDictionary时表示是用户自定义的本地通知response.notification.request.content.userInfo
 */
- (void) onNotificationClicked:(id) msg pushType:(UPushType)pushType;

/**
 @brief 消息撤回
 @param data            撤回消息内容
 @param timestamp      撤回时间
 @param message        被撤回的消息
 */
- (void) onRevoke:(NSDictionary*) data timestamp:(uint64_t) timestamp message:(UMessage* _Nullable) message;

/**
 @brief 状态监听
 @param status    参照共通 - 状态码
 */
- (void) onStatus:(int) status;

/**
 @brief pushToken监听
 @param code              0 成功,小于0失败,参照共通 - 错误码
 @param pushToken         推送设备唯一标示
 @param userId           绑定到pushToken的用户ID,未绑定时为空
 */
- (void) onPushToken:(int)code pushToken:(NSString*) pushToken userId:(NSString*) userId;

/**
 @brief 账号在其他设备登录监听
 @param info         JSON字符串, keys: ip, platform
 */
- (void) onRegisteredOnAnotherDevice:(NSString*) info;

/**
 @brief 注销完成监听
 */
- (void) onUnregister;

/**
 @brief 绑定用户监听
 @param code      0成功,小于0失败,参照错误码
 */
- (void) onBindUser:(int)code;

/**
 @brief 本地通知将要显示
 @param content       >= ios10 UNMutableNotificationContent else UILocalNotification
 @param message      消息
 @param revoke       是否为撤回消息
 */
- (BOOL) onLocalNotificationWillAppear:(NSObject*)content message:(UMessage*)message revoke:(BOOL)revoke;

@end

UPushNotificationOptions #

  • 兼容 UNAuthorizationOptions, UIUserNotificationType
typedef NS_OPTIONS(NSUInteger, UPushNotificationOptions) {

    // UIUserNotificationTypeNone, 只有穿透推送,不注册APNS
    UPushNotificationOptionPassThrough    = 0,

    // UIUserNotificationTypeBadge, UNAuthorizationOptionBadge
    UPushNotificationOptionBadge   = (1 << 0),

    // UIUserNotificationTypeSound, UNAuthorizationOptionSound
    UPushNotificationOptionSound   = (1 << 1),

    // UIUserNotificationTypeAlert,UNAuthorizationOptionAlert
    UPushNotificationOptionAlert   = (1 << 2),

    // UNAuthorizationOptionCarPlay
    UPushNotificationOptionCarPlay = (1 << 3),

    // UNAuthorizationOptionCriticalAlert
    UPushNotificationOptionCriticalAlert  = (1 << 4),

    // UNAuthorizationOptionProvidesAppNotificationSettings
    UPushNotificationOptionProvidesAppNotificationSettings = (1 << 5),

    // UNAuthorizationOptionProvisional
    UPushNotificationOptionProvisional = (1 << 6),

    // UNAuthorizationOptionAnnouncement
    UPushNotificationOptionAnnouncement = (1 << 7),

    // UPush独有的,控制是否开启VOIP推送
    UPushNotificationOptionVoip = (1 << 15),
};

UPushType #

typedef NS_ENUM(NSUInteger, UPushType) {
    UPushType_NONE,
    
    // 穿透消息
    UPushType_PASS,

    // 离线消息
    UPushType_OFFLINE,

    // APNS消息
    UPushType_APNS,

    // VOIP消息
    UPushType_VOIP,
};

消息 #

  • 高亮属性不为空,其他属性可能是为空





 




 




 




 




























@interface UMessage : NSObject<NSCopying>

/**
 * 消息唯一标示
 */
@property (copy, nonatomic) NSString *msgId;

/**
 * 消息体
 */
@property (copy, nonatomic) NSString *payload;

/**
 * 消息类型
 */
@property (assign, nonatomic) int type;

/**
 * 通知类型 
 */
@property (assign, nonatomic) int notifyType;

/**
 * 消息来源标示/发送者ID
 */
@property (copy, nonatomic) NSString *fromId;

/**
 * 消息目标ID/接收者ID,默认或为空表示是自己,群消息时为群组ID
 */
@property (copy, nonatomic) NSString *toId;

/**
 * 额外扩展属性键值对
 */
@property (copy, nonatomic) NSDictionary *extra;

/**
 * 通知栏对象
 */
@property (copy, nonatomic) UMessageNotification *notification;

/**
 * 消息画像
 */
@property (copy, nonatomic) UMessagePortrait *portrait;

@end
notifyType 说明

参照 NotifyType


消息画像 #

@interface UMessagePortrait : NSObject<NSCopying>

/**
 * fromId显示名
 */
@property (copy, nonatomic) NSString *name;

/**
 * fromId头像
 */
@property (copy, nonatomic) NSString *avatar;

/**
 * 群组名
 */
@property (copy, nonatomic) NSString *groupName;

 /**
  * 群组头像
  */
@property (copy, nonatomic) NSString *groupAvatar;

 /**
  * 通知类型
  */
@property (assign, nonatomic) int notifyType;

@end

通知栏 #

@interface UMessageNotification : NSObject<NSCopying>

 /**
  * 标题
  */
@property (copy, nonatomic) NSString *title;

/**
 * 子标题
 */
@property (copy, nonatomic) NSString *subTitle;

/**
 *  通知栏显示内容
 */
@property (copy, nonatomic) NSString *body;

/**
 *  角标数
 */
@property (assign, nonatomic) int badge;

/**
 * 通知音
 */
@property (copy, nonatomic) NSString *sound;

/**
 * 自定义通知栏点击动作
 */
@property (copy, nonatomic) NSString *action;

/**
 * 大图标/消息头像/消息画像
 */
@property (copy, nonatomic) NSString *largeIcon;

/**
 * 类别
 */
@property (copy, nonatomic) NSString* category;

@end

上次更新: 4/16/2024, 6:08:51 PM