diff --git a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSInAppMessageMigrationController.m b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSInAppMessageMigrationController.m index a9410fbe0..a0a10a82f 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSInAppMessageMigrationController.m +++ b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSInAppMessageMigrationController.m @@ -77,15 +77,6 @@ + (void)migrateToOSInAppMessageInternal { [OneSignalLog onesignalLog:ONE_S_LL_DEBUG message:[NSString stringWithFormat:@"Migrating OSInAppMessage from version: %ld", sdkVersion]]; [NSKeyedUnarchiver setClass:[OSInAppMessageInternal class] forClassName:@"OSInAppMessage"]; - // Messages Array - NSArray *messages = [OneSignalUserDefaults.initStandard getSavedCodeableDataForKey:OS_IAM_MESSAGES_ARRAY - defaultValue:[NSArray new]]; - if (messages && messages.count) { - [NSKeyedArchiver setClassName:@"OSInAppMessageInternal" forClass:[OSInAppMessageInternal class]]; - [OneSignalUserDefaults.initStandard saveCodeableDataForKey:OS_IAM_MESSAGES_ARRAY withValue:messages]; - } else { - [OneSignalUserDefaults.initStandard saveCodeableDataForKey:OS_IAM_MESSAGES_ARRAY withValue:nil]; - } // Redisplay Messages Dict NSMutableDictionary *redisplayedInAppMessages = [[NSMutableDictionary alloc] initWithDictionary:[OneSignalUserDefaults.initStandard getSavedCodeableDataForKey:OS_IAM_REDISPLAY_DICTIONARY defaultValue:[NSMutableDictionary new]]]; diff --git a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.h b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.h index d37e3577e..b5d443112 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.h +++ b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.h @@ -51,7 +51,6 @@ NS_ASSUME_NONNULL_BEGIN + (void)start; + (void)removeInstance; - (void)presentInAppMessage:(OSInAppMessageInternal *)message; -- (void)updateInAppMessagesFromCache; - (void)getInAppMessagesFromServer:(NSString * _Nullable)subscriptionId; - (void)messageViewImpressionRequest:(OSInAppMessageInternal *)message; - (void)messageViewPageImpressionRequest:(OSInAppMessageInternal *)message withPageId:(NSString *)pageId; diff --git a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.m b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.m index b3c7305bb..b4e9efeb2 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.m +++ b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.m @@ -207,8 +207,7 @@ - (instancetype)init { self.dateGenerator = ^ NSTimeInterval { return [[NSDate date] timeIntervalSince1970]; }; - self.messages = [OneSignalUserDefaults.initStandard getSavedCodeableDataForKey:OS_IAM_MESSAGES_ARRAY - defaultValue:[NSArray new]]; + self.messages = [NSArray new]; [self initializeTriggerController]; self.messageDisplayQueue = [NSMutableArray new]; self.clickListeners = [NSMutableArray new]; @@ -242,17 +241,11 @@ - (void)initializeTriggerController { dateFromString:timeSinceLastMessage]]; } -- (void)updateInAppMessagesFromCache { - self.messages = [OneSignalUserDefaults.initStandard getSavedCodeableDataForKey:OS_IAM_MESSAGES_ARRAY defaultValue:[NSArray new]]; - [self evaluateMessages]; -} - - (void)getInAppMessagesFromServer:(NSString *)subscriptionId { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:@"getInAppMessagesFromServer"]; if (!subscriptionId) { - [self updateInAppMessagesFromCache]; return; } @@ -326,7 +319,6 @@ - (void)attemptFetchWithRetries:(NSString *)subscriptionId NSDictionary* responseHeaders = errorInfo[@"headers"]; if (!statusCode) { - [self updateInAppMessagesFromCache]; return; } @@ -354,9 +346,6 @@ - (void)attemptFetchWithRetries:(NSString *)subscriptionId } } else if (code >= 500 && code <= 599) { [OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:@"Server error, skipping retries"]; - [self updateInAppMessagesFromCache]; - } else { - [self updateInAppMessagesFromCache]; } }]; } @@ -401,23 +390,15 @@ - (void)fetchInAppMessagesWithoutToken:(NSString *)subscriptionId { [self updateInAppMessagesFromServer:messages]; return; } - [self updateInAppMessagesFromCache]; }); } onFailure:^(NSError *error) { [OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:[NSString stringWithFormat:@"getInAppMessagesFromServer failure: %@", error.localizedDescription]]; - [self updateInAppMessagesFromCache]; }]; } - (void)updateInAppMessagesFromServer:(NSArray *)newMessages { [OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:@"updateInAppMessagesFromServer"]; self.messages = newMessages; - - // Cache if messages passed in are not null, this method is called from on_session for - // new messages and cached when foregrounding app - if (self.messages) - [OneSignalUserDefaults.initStandard saveCodeableDataForKey:OS_IAM_MESSAGES_ARRAY withValue:self.messages]; - self.calledLoadTags = NO; [self resetRedisplayMessagesBySession]; [self evaluateMessages]; @@ -438,11 +419,6 @@ - (void)deleteInactiveMessage:(OSInAppMessageInternal *)message { NSMutableArray *newMessagesArray = [NSMutableArray arrayWithArray:self.messages]; [newMessagesArray removeObject: message]; self.messages = newMessagesArray; - if (self.messages) { - [OneSignalUserDefaults.initStandard saveCodeableDataForKey:OS_IAM_MESSAGES_ARRAY withValue:self.messages]; - } else { - [OneSignalUserDefaults.initStandard removeValueForKey:OS_IAM_MESSAGES_ARRAY]; - } } /* diff --git a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/OSInAppMessagingDefines.h b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/OSInAppMessagingDefines.h index 9bda4a68b..af6d87162 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/OSInAppMessagingDefines.h +++ b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/OSInAppMessagingDefines.h @@ -73,7 +73,6 @@ typedef NS_ENUM(NSUInteger, OSTriggerOperatorType) { #define OS_IAM_CLICKED_SET_KEY @"OS_IAM_CLICKED_SET" #define OS_IAM_IMPRESSIONED_SET_KEY @"OS_IAM_IMPRESSIONED_SET" #define OS_IAM_PAGE_IMPRESSIONED_SET_KEY @"OS_IAM_PAGE_IMPRESSIONED_SET" -#define OS_IAM_MESSAGES_ARRAY @"OS_IAM_MESSAGES_ARRAY" #define OS_IAM_REDISPLAY_DICTIONARY @"OS_IAM_REDISPLAY_DICTIONARY" #define OS_IAM_TIME_SINCE_LAST_MESSAGE_KEY @"OS_IAM_TIME_SINCE_LAST_MESSAGE" diff --git a/iOS_SDK/OneSignalSDK/Source/OneSignal.m b/iOS_SDK/OneSignalSDK/Source/OneSignal.m index b18d5ffdc..cb2bc54ea 100755 --- a/iOS_SDK/OneSignalSDK/Source/OneSignal.m +++ b/iOS_SDK/OneSignalSDK/Source/OneSignal.m @@ -417,9 +417,6 @@ + (void)startNewSessionInternal { // [OneSignalLocation sendLocation]; // [self executePendingLiveActivityUpdates]; // [self receivedInAppMessageJson:results[@"push"][@"in_app_messages"]]; // go to controller - - // on failure: - // [OSMessagingController.sharedInstance updateInAppMessagesFromCache]; // go to controller } + (void)startInAppMessages {