diff --git a/Classes/BITFeedbackManager.h b/Classes/BITFeedbackManager.h index afdf08b9..3ef85c45 100644 --- a/Classes/BITFeedbackManager.h +++ b/Classes/BITFeedbackManager.h @@ -225,7 +225,6 @@ typedef NS_ENUM(NSInteger, BITFeedbackObservationMode) { */ @property (nonatomic, readwrite) BITFeedbackObservationMode feedbackObservationMode; - /** Prefill feedback compose message user interface with the items given. diff --git a/Classes/BITFeedbackManager.m b/Classes/BITFeedbackManager.m index 4a0d1056..7dde9347 100644 --- a/Classes/BITFeedbackManager.m +++ b/Classes/BITFeedbackManager.m @@ -1,7 +1,7 @@ /* * Author: Andreas Linde * - * Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH. + * Copyright (c) 2012-2016 HockeyApp, Bit Stadium GmbH. * All rights reserved. * * Permission is hereby granted, free of charge, to any person @@ -450,7 +450,7 @@ - (void)loadMessages { if ([unarchiver containsValueForKey:kBITFeedbackUserDataAsked]) _didAskUserData = YES; - + if ([unarchiver containsValueForKey:kBITFeedbackToken]) { self.token = [unarchiver decodeObjectForKey:kBITFeedbackToken]; [self addStringValueToKeychain:self.token forKey:kBITFeedbackToken]; @@ -467,7 +467,11 @@ - (void)loadMessages { self.token = nil; } } - + + if ([self shouldForceNewThread]) { + self.token = nil; + } + if ([unarchiver containsValueForKey:kBITFeedbackDateOfLastCheck]) self.lastCheck = [unarchiver decodeObjectForKey:kBITFeedbackDateOfLastCheck]; @@ -657,6 +661,15 @@ - (void)deleteAllMessages { [self saveMessages]; } +- (BOOL)shouldForceNewThread { + if (self.delegate && [self.delegate respondsToSelector:@selector(forceNewFeedbackThreadForFeedbackManager:)]) { + return [self.delegate forceNewFeedbackThreadForFeedbackManager:self]; + } + else { + return NO; + } +} + #pragma mark - User @@ -729,9 +742,13 @@ - (void)updateMessageListFromResponse:(NSDictionary *)jsonDictionary { NSString *token = [jsonDictionary objectForKey:@"token"]; NSDictionary *feedbackObject = [jsonDictionary objectForKey:@"feedback"]; if (feedback && token && feedbackObject) { - // update the thread token, which is not available until the 1st message was successfully sent - self.token = token; - + if ([self shouldForceNewThread]) { + self.token = nil; + } else { + // update the thread token, which is not available until the 1st message was successfully sent + self.token = token; + } + self.lastCheck = [NSDate date]; // add all new messages diff --git a/Classes/BITFeedbackManagerDelegate.h b/Classes/BITFeedbackManagerDelegate.h index 64449694..9afb8894 100644 --- a/Classes/BITFeedbackManagerDelegate.h +++ b/Classes/BITFeedbackManagerDelegate.h @@ -1,7 +1,7 @@ /* - * Author: Stephan Diederich + * Authors: Stephan Diederich, Benjamin Scholtysik * - * Copyright (c) 2013-2014 HockeyApp, Bit Stadium GmbH. + * Copyright (c) 2013-2016 HockeyApp, Bit Stadium GmbH. * All rights reserved. * * Permission is hereby granted, free of charge, to any person @@ -82,6 +82,16 @@ NS_ASSUME_NONNULL_BEGIN */ - (nullable NSArray *)preparedItemsForFeedbackManager:(BITFeedbackManager *)feedbackManager; +/** + * Indicates if a new thread should be created for each new feedback message + * + * Setting it to `YES` will force a new thread whenever a new message is sent as + * opposed to the default resume thread behaviour. + * + * @return A BOOL indicating if each feedback message should be sent as a new thread. + */ +- (BOOL)forceNewFeedbackThreadForFeedbackManager:(BITFeedbackManager *)feedbackManager; + @end NS_ASSUME_NONNULL_END