diff --git a/AWSIoT/AWSIoTDataManager.h b/AWSIoT/AWSIoTDataManager.h index 4b5bb6dce72..fd85ff75304 100644 --- a/AWSIoT/AWSIoTDataManager.h +++ b/AWSIoT/AWSIoTDataManager.h @@ -796,6 +796,8 @@ enableVersioning: BOOL, set to NO to disable versioning (default YES) enableForeignStateUpdateNotifications: BOOL, set to YES to enable foreign state updates (default NO) enableStaleDiscards: BOOL, set to NO to disable discarding stale updates (default YES) enableIgnoreDeltas: BOOL, set to YES to disable delta updates (default NO) +enableIgnoreDeletes: BOOL, set to YES to disable delete updates (default NO) +enableIgnoreRejecteds: BOOL, set to YES to disable all/rejected updates (default NO) QoS: AWSIoTMQTTQoS (default AWSIoTMQTTQoSMessageDeliveryAttemptedAtMostOnce) shadowOperationTimeoutSeconds: double, device shadow operation timeout (default 10.0) diff --git a/AWSIoT/AWSIoTDataManager.m b/AWSIoT/AWSIoTDataManager.m index e568faaf079..098d7d52877 100644 --- a/AWSIoT/AWSIoTDataManager.m +++ b/AWSIoT/AWSIoTDataManager.m @@ -48,6 +48,8 @@ @interface AWSIoTDataShadow:NSObject @property(atomic, assign) BOOL enableStaleDiscards; @property(atomic, assign) BOOL enableIgnoreDeltas; @property(atomic, assign) BOOL enableIgnoreDocuments; +@property(atomic, assign) BOOL enableIgnoreDeletes; +@property(atomic, assign) BOOL enableIgnoreRejecteds; @property(atomic, assign) UInt32 version; @property(nonatomic, strong) NSString *clientToken; @property(atomic, assign) AWSIoTMQTTQoS qos; @@ -73,6 +75,8 @@ - (instancetype)initWithName:(NSString *)name discardStaleUpdates:(BOOL)enableStaleDiscards discardDeltas:(BOOL)enableIgnoreDeltas discardDocuments:(BOOL)enableIgnoreDocuments + discardDeletes:(BOOL)enableIgnoreDeletes + discardRejecteds:(BOOL)enableIgnoreRejecteds updateOnForeignChanges:(BOOL)enableForeignStateUpdateNotifications operationTimeout:(NSTimeInterval)operationTimeoutSeconds QoS:(AWSIoTMQTTQoS)qos @@ -85,6 +89,8 @@ - (instancetype)initWithName:(NSString *)name _enableStaleDiscards = enableStaleDiscards; _enableIgnoreDeltas = enableIgnoreDeltas; _enableIgnoreDocuments = enableIgnoreDocuments; + _enableIgnoreDeletes = enableIgnoreDeletes; + _enableIgnoreRejecteds = enableIgnoreRejecteds; _enableForeignStateUpdateNotifications = enableForeignStateUpdateNotifications; _callback = callback; _operationTimeout = operationTimeoutSeconds; @@ -1218,6 +1224,8 @@ - (BOOL) registerWithShadow:(NSString *)name discardStaleUpdates:YES discardDeltas:NO discardDocuments:NO + discardDeletes:NO + discardRejecteds:NO updateOnForeignChanges:NO operationTimeout:10.0 QoS:AWSIoTMQTTQoSMessageDeliveryAttemptedAtMostOnce @@ -1257,6 +1265,14 @@ - (BOOL) registerWithShadow:(NSString *)name if (numberOptionValue != nil) { shadow.enableIgnoreDocuments = [numberOptionValue integerValue]; } + numberOptionValue = [options valueForKey:@"enableIgnoreDeletes"]; + if (numberOptionValue != nil) { + shadow.enableIgnoreDeletes = [numberOptionValue integerValue]; + } + numberOptionValue = [options valueForKey:@"enableIgnoreRejecteds"]; + if (numberOptionValue != nil) { + shadow.enableIgnoreRejecteds = [numberOptionValue integerValue]; + } numberOptionValue = [options valueForKey:@"QoS"]; if (numberOptionValue != nil) { shadow.qos = [numberOptionValue integerValue]; @@ -1276,12 +1292,17 @@ - (BOOL) registerWithShadow:(NSString *)name operations:@[[NSNumber numberWithInteger:AWSIoTShadowOperationTypeUpdate]] statii:@[[NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeDocuments]] ]; } + if (shadow.enableIgnoreDeletes == NO) { + NSArray * statii = shadow.enableIgnoreRejecteds ? @[[NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeAccepted]] : @[[NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeAccepted], [NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeRejected]]; + [self createSubscriptionsForShadow:shadow + operations:@[[NSNumber numberWithInteger:AWSIoTShadowOperationTypeDelete]] + statii:statii]; + } + NSArray * statii = shadow.enableIgnoreRejecteds ? @[[NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeAccepted]] : @[[NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeAccepted], [NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeRejected]]; [self createSubscriptionsForShadow:shadow operations:@[[NSNumber numberWithInteger:AWSIoTShadowOperationTypeUpdate], - [NSNumber numberWithInteger:AWSIoTShadowOperationTypeGet], - [NSNumber numberWithInteger:AWSIoTShadowOperationTypeDelete]] - statii:@[[NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeAccepted], - [NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeRejected]]]; + [NSNumber numberWithInteger:AWSIoTShadowOperationTypeGet]] + statii:statii]; // // Persistently subscribe to the special topics for this shadow. //