Store the app identifier with the feedback thread. So in case they change by accident, new posts will cause a new thread in the current app to be created

This commit is contained in:
Andreas Linde 2012-10-22 01:10:18 +02:00
parent 9e436f3d26
commit f09ea53fba
3 changed files with 18 additions and 2 deletions

View File

@ -47,6 +47,7 @@
#define kBITFeedbackName @"HockeyFeedbackName" #define kBITFeedbackName @"HockeyFeedbackName"
#define kBITFeedbackEmail @"HockeyFeedbackEmail" #define kBITFeedbackEmail @"HockeyFeedbackEmail"
#define kBITFeedbackLastMessageID @"HockeyFeedbackLastMessageID" #define kBITFeedbackLastMessageID @"HockeyFeedbackLastMessageID"
#define kBITFeedbackAppID @"HockeyFeedbackAppID"
@implementation BITFeedbackManager { @implementation BITFeedbackManager {
@ -320,6 +321,17 @@
if ([unarchiver containsValueForKey:kBITFeedbackToken]) if ([unarchiver containsValueForKey:kBITFeedbackToken])
self.token = [unarchiver decodeObjectForKey:kBITFeedbackToken]; self.token = [unarchiver decodeObjectForKey:kBITFeedbackToken];
if ([unarchiver containsValueForKey:kBITFeedbackAppID]) {
NSString *appID = [unarchiver decodeObjectForKey:kBITFeedbackAppID];
// the stored thread is from another application identifier, so clear the token
// which will cause the new posts to create a new thread on the server for the
// current app identifier
if ([appID compare:self.appIdentifier] != NSOrderedSame) {
self.token = nil;
}
}
if ([unarchiver containsValueForKey:kBITFeedbackDateOfLastCheck]) if ([unarchiver containsValueForKey:kBITFeedbackDateOfLastCheck])
self.lastCheck = [unarchiver decodeObjectForKey:kBITFeedbackDateOfLastCheck]; self.lastCheck = [unarchiver decodeObjectForKey:kBITFeedbackDateOfLastCheck];
@ -356,6 +368,9 @@
if (self.token) if (self.token)
[archiver encodeObject:self.token forKey:kBITFeedbackToken]; [archiver encodeObject:self.token forKey:kBITFeedbackToken];
if (self.appIdentifier)
[archiver encodeObject:self.appIdentifier forKey:kBITFeedbackAppID];
if (self.userID) if (self.userID)
[archiver encodeObject:self.userID forKey:kBITFeedbackUserID]; [archiver encodeObject:self.userID forKey:kBITFeedbackUserID];

View File

@ -26,7 +26,6 @@
NSDateFormatter *_rfc3339Formatter; NSDateFormatter *_rfc3339Formatter;
NSString *_appIdentifier;
BOOL _isAppStoreEnvironment; BOOL _isAppStoreEnvironment;
} }
@ -54,7 +53,7 @@
- (id)initWithAppIdentifier:(NSString *)appIdentifier isAppStoreEnvironemt:(BOOL)isAppStoreEnvironment { - (id)initWithAppIdentifier:(NSString *)appIdentifier isAppStoreEnvironemt:(BOOL)isAppStoreEnvironment {
if ((self = [self init])) { if ((self = [self init])) {
_appIdentifier = appIdentifier; self.appIdentifier = appIdentifier;
_isAppStoreEnvironment = isAppStoreEnvironment; _isAppStoreEnvironment = isAppStoreEnvironment;
} }

View File

@ -14,6 +14,8 @@
@interface BITHockeyBaseManager() @interface BITHockeyBaseManager()
@property (nonatomic, retain) NSString *appIdentifier;
- (id)initWithAppIdentifier:(NSString *)appIdentifier isAppStoreEnvironemt:(BOOL)isAppStoreEnvironment; - (id)initWithAppIdentifier:(NSString *)appIdentifier isAppStoreEnvironemt:(BOOL)isAppStoreEnvironment;
- (void)startManager; - (void)startManager;