Skip to content

Message Management

The content below introduces how to manage messages, including device alert, automation and scene execution.

Feature Description

objc
#import <QuecUserKit/QuecUserKit.h>
/// Initialize
[QuecUserMessageService sharedInstance]

Delete Message

API

Delete a message.

objc
- (void)deleteMessageByMsgId:(NSString *)msgId
                    language:(NSString *)language
                     success:(QuecVoidBlock)success
                     failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
msgIdYList of message IDs to be read. Separate multiple IDs by commas.
languageNVoice.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[[QuecUserMessageService sharedInstance] deleteMessageByMsgId:@"messageId" language:@"cn" success:^{
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Read Message

API

Read a message or messages in batches (call the new API below when reading messages by label).

objc
- (void)readMessageByMsgIdList:(NSString *)msgIdList
                        msgType:(int)msgType
                        success:(void(^)(QuecReadMsgModel *model))success
                        failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
msgIdListNList of message IDs to be read. Separate multiple IDs by commas. Read all the messages if this parameter is omitted.
msgTypeNThe random combination pf the received message types.
1-Device notification
2-Device alert
3-Device fault
4-System messages
successNCallback function of successful request.
failureNCallback function of failed request.

QuecReadMsgModel Definition

ParameterTypeDescription
successListNSArray<QuecReadMsgListModel *>List of successful executions.
failureListNSArray<QuecReadMsgListModel *>List of failed executions.

QuecReadMsgListModel Definition

ParameterTypeDescription
msgIDNSStringMessage ID.
failureMsgNSStringReasons for reading failure (only valid for failurelist).

Example

objc
[QuecUserMessageService.sharedInstance readMessageByMsgIdList:@"MsgIdList" msgType:1 success:^(QuecReadMsgModel * _Nonnull model) {
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Query Message List

API

Query a message list by message type (call the new API below when reading messages by label).

objc
- (void)getUserMessageListByPageNumber:(NSInteger)pageNumber
                              pageSize:(NSInteger)pageSize
                               msgType:(NSInteger)msgType
                                isRead:(BOOL)isRead
                             deviceKey:(NSString *)deviceKey
                            productKey:(NSString *)productKey
                               success:(void(^)(NSArray<QuecUserMessageListModel *> *list, NSInteger total))success
                               failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
pageNumberNPage number. Default value: 1.
pageSizeNPage size. Default value: 10.
msgTypeNThe random combination pf the received message types. Separate multiple types by commas.
1-Device notification
2-Device alert
3-Device fault
4-System messages
isReadNWhether the message is read or not.
deviceKeyNDeviceKey.
productKeyNProductKey.
successNCallback function of successful request.
failureNCallback function of failed request.

QuecUserMessageListModel Definition

ParameterTypeDescription
msgIdNSStringMassage ID.
msgTypeNSIntegerMessage type.
1-Device notification
2-Device alert
3-Device fault
4-System messages
isReadBOOLWhether the message is read or not.
titleNSStringTitle.
contentNSStringContent.
pkNSStringProductKey.
dkNSStringDeviceKey.
addTimeNSUIntegerThe time to add the message.
readTimeNSUIntegerThe time to read the message.
shareCodeNSStringShare code.
sceneIconNSStringScene icon.
sceneNameNSStringScene name.
sceneExecuteTimeNSStringScene execution time.
executeIdNSStringScene execution ID.
logIdNSStringAutomation log ID.
automationIdNSStringAutomation ID.
firstLabelNSStringLabel of the first-level messages.
secondaryLabelNSStringLabel of the second-level messages.

Example

objc
[QuecUserMessageService.sharedInstance getUserMessageListByPageNumber:1 pageSize:10 msgType:1 isRead:NO deviceKey:@"deviceKey" productKey:@"productKey" success:^(NSArray<QuecUserMessageListModel *> * _Nonnull list, NSInteger total) {
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Upload PushToken

API

Upload a PushToken. Aliyun's DeviceID (Google's FCM Token in overseas) must be obtained before this API is called.

objc
- (void)addPushToken:(NSString *)pushToken
              success:(QuecVoidBlock)success
              failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
pushTokenYPushToken (Aliyun‘s DeviceID or Google's FCM Token).
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecUserMessageService.sharedInstance addPushToken:@"pushToken" success:^{
            /// Next Action
        } failure:^(NSError *error) {
            NSLog(@"check error: %@", error);
        }];

Delete PushToken

API

Delete a bound PushToken. The cached Aliyun's DeviceID (Google's FCM Token in overseas) must be obtained before this API is called.

objc
- (void)deletePushToken:(NSString *)pushToken
                 success:(QuecVoidBlock)success
                 failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
pushTokenYPushToken (Aliyun‘s DeviceID or Google's FCM Token).
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[QuecUserMessageService.sharedInstance deletePushToken:@"pushToken" success:^{
            /// Next Action
        } failure:^(NSError *error) {
            NSLog(@"check error: %@", error);
        }];

Query Message List

API

Query a message list by label.

objc
- (void)getUserMessageListByPageNumber:(NSInteger)pageNumber
                              pageSize:(NSInteger)pageSize
                        firstLabelList:(NSString *)firstLabelList
                    secondaryLabelList:(NSString *)secondaryLabelList
                                isRead:(BOOL)isRead
                             deviceKey:(NSString * _Nullable)deviceKey
                            productKey:(NSString * _Nullable)productKey
                               success:(void (^)(NSArray<QuecUserMessageListModel *> *, NSInteger))success
                               failure:(void (^)(NSError *))failure;

Parameter

ParameterRequiredDescription
pageNumberNPage number. Default value: 1.
pageSizeNPage size. Default value: 10.
firstLabelListYLabel list of the first-level messages. Separate multiple labels by commas.
1-System
2-Smart
3-Device
secondaryLabelListYLabel list of the second-level messages. Separate multiple labels by commas.
1-Privacy
2-Service
3-Automation
4-Scene
5-Device notification
6-Device alert
7-Device fault
8-OTA
isReadYWhether the message is read or not.
deviceKeyYDeviceKey.
productKeyYProductKey.
successNCallback function of successful request.
failureNCallback function of failed request.

QuecUserMessageListModel Definition

ParameterTypeDescription
msgIdNSStringMassage ID.
msgTypeNSIntegerMessage type.
1-Device notification
2-Device alert
3-Device fault
4-System messages
isReadBOOLWhether the message is read or not.
titleNSStringTitle.
contentNSStringContent.
pkNSStringProductKey.
dkNSStringDeviceKey.
addTimeNSUIntegerThe time to add the message.
readTimeNSUIntegerThe time to read the message.
shareCodeNSStringShare code.
sceneIconNSStringScene icon.
sceneNameNSStringScene name.
sceneExecuteTimeNSStringScene execution time.
executeIdNSStringScene execution ID.
logIdNSStringAutomation log ID.
automationIdNSStringAutomation ID.
firstLabelNSStringLabel of the first-level messages.
secondaryLabelNSStringLabel of the second-level messages.

Example

objc
[QuecUserMessageService.sharedInstance getUserMessageListByPageNumber:1 pageSize:10 firstLabelList:@"firstLabelList" secondaryLabelList:@"secondaryLabelList" isRead:NO deviceKey:@"dk" productKey:@"pk" success:^(NSArray<QuecUserMessageListModel *> * _Nonnull, NSInteger) {
        /// Next Action
    } failure:^(NSError * _Nonnull) {
        NSLog(@"check error: %@", error);
    }]

Read Message

API

Read a message by label.

objc
- (void)readMessageByMsgIdList:(NSString * _Nullable)msgIdList
                firstLabelList:(NSString * _Nullable)firstLabelList
            secondaryLabelList:(NSString * _Nullable)secondaryLabelList
                       success:(void (^)(QuecReadMsgModel *model))success
                       failure:(void (^)(NSError *))failure;

Parameter

ParameterRequiredDescription
msgIdListYList of message IDs to be read. Separate multiple IDs by commas. Read all the messages if this parameter is omitted.
firstLabelListYLabel list of the first-level messages. Separate multiple labels by commas.
1-System
2-Smart
3-Device
secondaryLabelListYLabel list of the second-level messages. Separate multiple labels by commas.
1-Privacy
2-Service
3-Automation
4-Scene
5-Device notification
6-Device alert
7-Device fault
8-OTA
successNCallback function of successful request.
failureNCallback function of failed request.

QuecReadMsgModel Definition

ParameterTypeDescription
successListNSArray<QuecReadMsgListModel *>List of successful executions.
failureListNSArray<QuecReadMsgListModel *>List of failed executions.

QuecReadMsgListModel Definition

ParameterTypeDescription
msgIDNSStringMessage ID.
failureMsgNSStringReasons for reading failure (only valid for failurelist).

Example

objc
[QuecUserMessageService.sharedInstance readMessageByMsgIdList:@"messageId" firstLabelList:@"firstLabelList" secondaryLabelList:@"" success:^(QuecReadMsgModel * _Nonnull msgModel) {
        /// Next Action
    } failure:^(NSError * _Nonnull error) {
        NSLog(@"check error: %@", error);
    }];

Query Unread Message Number

API

Query the number of unread messages, which can be used to mark the user's message reading state.

objc
- (void)getMsgStatsWithSuccess:(void(^)(QuecUserMessageStatsModel *statsModel))success failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
successNCallback function of successful request.
failureNCallback function of failed request.

QuecUserMessageStatsModel Definition

ParameterTypeDescription
smartQuecUserMessageUnReadModelSmart-related messages.
systemQuecUserMessageUnReadModelSystem-related messages.
deviceQuecUserMessageUnReadModelDevice-related messages.

QuecUserMessageUnReadModel Definition

ParameterTypeDescription
readNSIntegerThe number of read messages.
unReadNSIntegerThe number of unread messages.

Example

objc
[QuecUserMessageService.sharedInstance getMsgStatsWithSuccess:^(QuecUserMessageStatsModel * _Nonnull statsModel) {
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Query Type of Push Message Received by User

API

Query the type of push messages received by user.

objc
- (void)getMsgPushSettingWithSuccess:(void(^)(QuecPushSettingModel *data))success failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
successNCallback function of successful request.
failureNCallback function of failed request.

QuecPushSettingModel Definition

ParameterTypeDescription
deviceNotifyBOOLDevice push.
smartNotifyBOOLSmart push.
systemNotifyBOOLSystem push.
deviceQuecPushSettingItemModelConfiguration state of device push sub-properties.
smartQuecPushSettingItemModelConfiguration state of smart push sub-properties.
systemQuecPushSettingItemModelConfiguration state of system push sub-properties.

QuecPushSettingItemModel Definition

ParameterTypeDescription
appBOOLWhether system push is on.
smsBOOLWhether SMS push is on.
voiceBOOLWhether voice call push is on.

Example

objc
[[QuecUserMessageService sharedInstance] getMsgPushSettingWithSuccess:^(QuecPushSettingModel *pushSettingModel) {
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];

Set Type of Push Message Received by User

API

Set the type of push message received by user.

objc
- (void)setMsgPushSettingWithConfig:(QuecPushSettingModel *)config success:(QuecVoidBlock)success failure:(QuecErrorBlock)failure;

Parameter

ParameterRequiredDescription
configYSee QuecPushSettingModel Definition above. [Query Type of Push Message Received by User]
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[[QuecUserMessageService sharedInstance] setMsgPushSettingWithConfig:model success:^{
        /// Next Action
    } failure:^(NSError *error) {
        NSLog(@"check error: %@", error);
    }];