Skip to content

Commit

Permalink
Apptentive IOS SDK 5.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
weeeBox committed Mar 7, 2018
1 parent f24baf2 commit b53d1b1
Show file tree
Hide file tree
Showing 13 changed files with 238 additions and 220 deletions.
12 changes: 6 additions & 6 deletions Apptentive/Apptentive.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2305,7 +2305,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -2361,7 +2361,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -2393,7 +2393,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 86WML2UN43;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_CURRENT_VERSION = 3;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_PREFIX_HEADER = "Apptentive/Misc/ApptentiveConnect-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = "APPTENTIVE_DEBUG=1";
Expand All @@ -2415,7 +2415,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 86WML2UN43;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_CURRENT_VERSION = 3;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_PREFIX_HEADER = "Apptentive/Misc/ApptentiveConnect-Prefix.pch";
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
Expand Down Expand Up @@ -2466,7 +2466,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 86WML2UN43;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_CURRENT_VERSION = 3;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = ApptentiveDebugging/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -2485,7 +2485,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 86WML2UN43;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_CURRENT_VERSION = 3;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = ApptentiveDebugging/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down
2 changes: 1 addition & 1 deletion Apptentive/Apptentive/Apptentive.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FOUNDATION_EXPORT double ApptentiveVersionNumber;
FOUNDATION_EXPORT const unsigned char ApptentiveVersionString[];

/** The version number of the Apptentive SDK. */
#define kApptentiveVersionString @"5.0.2"
#define kApptentiveVersionString @"5.0.3"

/** The version number of the Apptentive API platform. */
#define kApptentiveAPIVersionString @"9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ extern NSString *NSStringFromApptentiveConversationState(ApptentiveConversationS
*/
@property (readonly, nonatomic) NSDictionary *userInfo;

/**
Returns true if conversation data is consistent.
*/
@property (readonly, nonatomic, getter=isConsistent) BOOL consistent;

/**
The delegate for the conversation.
*/
Expand Down
53 changes: 40 additions & 13 deletions Apptentive/Apptentive/Engagement/Model/ApptentiveConversation.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,6 @@ - (void)encodeWithCoder:(NSCoder *)coder {
[coder encodeObject:@1 forKey:ArchiveVersionKey];
}

- (void)setToken:(NSString *)token conversationID:(NSString *)conversationID personID:(NSString *)personID deviceID:(NSString *)deviceID {
[self setConversationIdentifier:conversationID JWT:token];
self.person.identifier = personID;
self.device.identifier = deviceID;
}

- (void)setConversationIdentifier:(NSString *)identifier JWT:(NSString *)JWT {
_identifier = [identifier copy];
_token = [JWT copy];
}

- (void)checkForDiffs {
ApptentiveAppRelease *currentAppRelease = [[ApptentiveAppRelease alloc] initWithCurrentAppRelease];
[currentAppRelease copyNonholonomicValuesFrom:self.appRelease];
Expand Down Expand Up @@ -365,6 +354,46 @@ - (BOOL)hasActiveState {
return _state == ApptentiveConversationStateAnonymous || _state == ApptentiveConversationStateLoggedIn;
}

- (BOOL)isConsistent {
if (self.state == ApptentiveConversationStateUndefined) {
ApptentiveLogError(ApptentiveLogTagConversation, @"Conversation state is undefined.");
return NO;
}

if (self.directoryName.length == 0) {
ApptentiveLogError(ApptentiveLogTagConversation, @"Conversation directory name is empty.");
return NO;
}

if (self.state == ApptentiveConversationStateAnonymous || self.state == ApptentiveConversationStateLoggedIn) {
if (self.identifier.length == 0) {
ApptentiveLogError(ApptentiveLogTagConversation, @"Conversation identifier is nil or empty for state %@.", NSStringFromApptentiveConversationState(self.state));

return NO;
}

if (self.token.length == 0) {
ApptentiveLogError(ApptentiveLogTagConversation, @"Conversation auth token is nil or empty for state %@.", NSStringFromApptentiveConversationState(self.state));

return NO;
}
}

if (self.state == ApptentiveConversationStateLoggedIn) {
if (self.userId.length == 0) {
ApptentiveLogError(ApptentiveLogTagConversation, @"Conversation userId is nil or empty for logged-in conversation.");
return NO;
}

if (self.encryptionKey.length == 0) {
ApptentiveLogError(ApptentiveLogTagConversation, @"Conversation encryption key is nil or empty for logged-in conversation.");
return NO;
}
}

return YES;
}

+ (void)deleteMigratedData {
[ApptentiveAppRelease deleteMigratedData];
[ApptentiveSDK deleteMigratedData];
Expand Down Expand Up @@ -487,8 +516,6 @@ @implementation ApptentiveMutableConversation
@dynamic lastMessageID;
@dynamic directoryName;

// FIXME: remove these methods

- (void)setToken:(NSString *)token conversationID:(NSString *)conversationID personID:(NSString *)personID deviceID:(NSString *)deviceID {
[self setConversationIdentifier:conversationID JWT:token];
self.person.identifier = personID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ - (nullable ApptentiveConversation *)loadConversationFromMetadataItem:(Apptentiv
}

ApptentiveConversation *conversation = [NSKeyedUnarchiver unarchiveObjectWithData:conversationData];
ApptentiveAssertNotNil(conversation, @"Failed to load conversation");
if (conversation == nil) {
ApptentiveLogError(ApptentiveLogTagConversation, @"Unable to load conversation from archive.");
return nil;
}

Expand All @@ -270,8 +270,11 @@ - (nullable ApptentiveConversation *)loadConversationFromMetadataItem:(Apptentiv
mutableConversation.encryptionKey = item.encryptionKey;
mutableConversation.userId = item.userId;
mutableConversation.token = item.JWT;

// TODO: check data consistency

if (!mutableConversation.isConsistent) {
ApptentiveLogError(ApptentiveLogTagConversation, @"Conversation data is inconsistent.");
return nil;
}

return mutableConversation;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ - (BOOL)isConsistent {

return NO;
}

if (self.JWT.length == 0) {
ApptentiveLogError(ApptentiveLogTagConversation, @"Conversation auth token is empty for state %@.", NSStringFromApptentiveConversationState(self.state));

return NO;
}
}

if (self.state == ApptentiveConversationStateLoggedIn) {
Expand Down
2 changes: 1 addition & 1 deletion Apptentive/Apptentive/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.0.0</string>
<string>5.0.3</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
12 changes: 7 additions & 5 deletions Apptentive/Apptentive/Misc/ApptentiveLogMonitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
extern NSNotificationName _Nonnull const ApptentiveManifestRawDataDidReceiveNotification;
extern NSString *_Nonnull const ApptentiveManifestRawDataKey;

extern NSString *ApptentiveLocalizedString(NSString *key, NSString *comment);

static NSString *const KeyEmailRecipients = @"emailRecipients";
static NSString *const KeyLogLevel = @"logLevel";

Expand Down Expand Up @@ -156,8 +158,8 @@ - (void)showReportUI {
UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

// create alert controller with "Send", "Continue" and "Discard" actions
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Apptentive" message:@"Troubleshooting mode" preferredStyle:UIAlertControllerStyleActionSheet];
[alertController addAction:[UIAlertAction actionWithTitle:@"Send Report"
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:ApptentiveLocalizedString(@"Apptentive", @"Apptentive") message:ApptentiveLocalizedString(@"Troubleshooting mode", @"Troubleshooting mode") preferredStyle:UIAlertControllerStyleActionSheet];
[alertController addAction:[UIAlertAction actionWithTitle:ApptentiveLocalizedString(@"Send Report", @"Send Report")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
window.hidden = YES;
Expand All @@ -169,12 +171,12 @@ - (void)showReportUI {
};
[self stop];
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Continue"
[alertController addAction:[UIAlertAction actionWithTitle:ApptentiveLocalizedString(@"Continue", @"Continue")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *_Nonnull action) {
window.hidden = YES;
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Discard Report"
[alertController addAction:[UIAlertAction actionWithTitle:ApptentiveLocalizedString(@"Discard Report", @"Discard Report")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *_Nonnull action) {
window.hidden = YES;
Expand Down Expand Up @@ -392,7 +394,7 @@ - (void)sendReportWithAttachedFiles:(NSArray<NSString *> *)files {
if (![MFMailComposeViewController canSendMail]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Apptentive Log Monitor" message:@"Unable to send email" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:ApptentiveLocalizedString(@"Apptentive Log Monitor", @"Apptentive Log Monitor") message:ApptentiveLocalizedString(@"Unable to send email", @"Unable to send email") delegate:nil cancelButtonTitle:ApptentiveLocalizedString(@"OK", @"OK") otherButtonTitles:nil];
[alertView show];
#pragma clang diagnostic pop

Expand Down
2 changes: 1 addition & 1 deletion Apptentive/ApptentiveDebugging/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.0.0</string>
<string>5.0.3</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion Apptentive/ApptentiveTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>5.0.3</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
Expand Down
Loading

0 comments on commit b53d1b1

Please sign in to comment.