Skip to content

Commit 9da0247

Browse files
committed
Update with bugfixes from 4.1.1
1 parent d213894 commit 9da0247

24 files changed

+164
-254
lines changed

Apptentive/Apptentive.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,7 @@
23772377
GCC_PREPROCESSOR_DEFINITIONS = "APPTENTIVE_DEBUG=1";
23782378
INFOPLIST_FILE = Apptentive/Info.plist;
23792379
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2380-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
2380+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
23812381
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
23822382
PRODUCT_BUNDLE_IDENTIFIER = com.apptentive.Apptentive;
23832383
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -2397,7 +2397,7 @@
23972397
GCC_PREFIX_HEADER = "Apptentive/Misc/ApptentiveConnect-Prefix.pch";
23982398
INFOPLIST_FILE = Apptentive/Info.plist;
23992399
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2400-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
2400+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
24012401
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
24022402
PRODUCT_BUNDLE_IDENTIFIER = com.apptentive.Apptentive;
24032403
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -2448,7 +2448,7 @@
24482448
DYLIB_INSTALL_NAME_BASE = "@rpath";
24492449
INFOPLIST_FILE = ApptentiveDebugging/Info.plist;
24502450
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2451-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
2451+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
24522452
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
24532453
PRODUCT_BUNDLE_IDENTIFIER = com.apptentive.ApptentiveDebugging;
24542454
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -2467,7 +2467,7 @@
24672467
DYLIB_INSTALL_NAME_BASE = "@rpath";
24682468
INFOPLIST_FILE = ApptentiveDebugging/Info.plist;
24692469
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2470-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
2470+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
24712471
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
24722472
PRODUCT_BUNDLE_IDENTIFIER = com.apptentive.ApptentiveDebugging;
24732473
PRODUCT_NAME = "$(TARGET_NAME)";

Apptentive/Apptentive/Apptentive.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ FOUNDATION_EXPORT double ApptentiveVersionNumber;
2020
FOUNDATION_EXPORT const unsigned char ApptentiveVersionString[];
2121

2222
/** The version number of the Apptentive SDK. */
23-
#define kApptentiveVersionString @"4.0.7"
23+
#define kApptentiveVersionString @"4.0.8"
2424

2525
/** The platform that the SDK is built for. */
2626
#define kApptentivePlatformString @"iOS"
@@ -514,7 +514,7 @@ typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) {
514514
515515
*/
516516

517-
- (BOOL)didReceveUserNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler;
517+
- (BOOL)didReceveUserNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler NS_AVAILABLE_IOS(10_0);
518518

519519
///-------------------------------------
520520
/// @name Attach Text, Images, and Files

Apptentive/Apptentive/Apptentive.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -933,8 +933,9 @@ @implementation ApptentiveNavigationController
933933
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
934934
self = [super initWithCoder:aDecoder];
935935
if (self) {
936-
if (!([UINavigationBar appearance].barTintColor || [UINavigationBar appearanceWhenContainedIn:[ApptentiveNavigationController class], nil].barTintColor)) {
937-
[UINavigationBar appearanceWhenContainedIn:[ApptentiveNavigationController class], nil].barTintColor = [UIColor whiteColor];
936+
937+
if (!([UINavigationBar appearance].barTintColor || [UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[ [ApptentiveNavigationController class] ]].barTintColor)) {
938+
[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[ [ApptentiveNavigationController class] ]].barTintColor = [UIColor whiteColor];
938939
}
939940
}
940941
return self;

Apptentive/Apptentive/Custom Views/ApptentiveHUDViewController.m

+7-13
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ @interface ApptentiveHUDViewController ()
1616

1717
@property (strong, nonatomic) IBOutlet UIView *HUDView;
1818
@property (nullable, strong, nonatomic) UIWindow *hostWindow;
19-
@property (strong, nonatomic) UIWindow *shadowWindow;
19+
@property (strong, nonatomic) UIWindow *previousKeyWindow;
2020
@property (strong, nonatomic) NSTimer *hideTimer;
2121
@property (strong, nonatomic) UIGestureRecognizer *tapGestureRecognizer;
2222

@@ -83,23 +83,14 @@ - (void)showInAlertWindow {
8383
self.interval = self.interval ?: 2.0;
8484
self.animationDuration = fmin(self.animationDuration ?: 0.25, self.interval / 2.0);
8585

86-
BOOL mustSizeWindow = ![[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){9, 0, 0}];
86+
self.hostWindow = [[ApptentivePassThroughWindow alloc] init];
87+
self.previousKeyWindow = [UIApplication sharedApplication].keyWindow;
8788

88-
if (mustSizeWindow) {
89-
self.hostWindow = [[ApptentivePassThroughWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
90-
} else {
91-
self.hostWindow = [[ApptentivePassThroughWindow alloc] init];
92-
}
93-
94-
self.hostWindow.hidden = NO;
89+
[self.hostWindow makeKeyAndVisible];
9590
self.hostWindow.rootViewController = self;
9691
self.hostWindow.windowLevel = UIWindowLevelAlert;
9792
self.hostWindow.backgroundColor = [UIColor clearColor];
9893

99-
if (mustSizeWindow) {
100-
self.hostWindow.frame = [UIScreen mainScreen].bounds;
101-
}
102-
10394
self.HUDView.alpha = 0.0;
10495
[UIView animateWithDuration:self.animationDuration animations:^{
10596
self.HUDView.alpha = 1;
@@ -110,11 +101,14 @@ - (void)showInAlertWindow {
110101

111102
- (IBAction)hide:(id)sender {
112103
[self.hideTimer invalidate];
104+
113105
[UIView animateWithDuration:self.animationDuration animations:^{
114106
self.HUDView.alpha = 0;
115107
} completion:^(BOOL finished) {
116108
self.hostWindow.hidden = YES;
109+
[self.previousKeyWindow makeKeyWindow];
117110
self.hostWindow = nil;
111+
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
118112
}];
119113
}
120114

Apptentive/Apptentive/Custom Views/ApptentiveNetworkImageView.m

+24-84
Original file line numberDiff line numberDiff line change
@@ -15,59 +15,45 @@
1515

1616
@interface ApptentiveNetworkImageView ()
1717

18-
@property (nullable, strong, nonatomic) NSURLConnection *connection;
19-
@property (nullable, strong, nonatomic) NSURLResponse *response;
20-
@property (nullable, strong, nonatomic) NSMutableData *imageData;
18+
@property (nullable, strong, nonatomic) NSURLSessionDataTask *task;
2119

2220
@end
2321

2422

2523
@implementation ApptentiveNetworkImageView
2624

27-
- (id)initWithFrame:(CGRect)frame {
28-
self = [super initWithFrame:frame];
29-
if (self) {
30-
// Initialization code
31-
_useCache = YES;
32-
}
33-
return self;
34-
}
35-
36-
- (void)awakeFromNib {
37-
[super awakeFromNib];
38-
self.useCache = YES;
39-
}
40-
4125
- (void)dealloc {
42-
[_connection cancel];
26+
[_task cancel];
4327
}
4428

4529
- (void)restartDownload {
46-
if (self.connection) {
47-
[self.connection cancel];
48-
self.connection = nil;
30+
if (self.task) {
31+
[self.task cancel];
32+
self.task = nil;
4933
}
34+
5035
if (self.imageURL) {
51-
NSURLRequest *request = [NSURLRequest requestWithURL:self.imageURL];
52-
53-
NSURLCache *cache = [[Apptentive sharedConnection].backend imageCache];
54-
BOOL cacheHit = NO;
55-
if (cache) {
56-
NSCachedURLResponse *cachedResponse = [cache cachedResponseForRequest:request];
57-
if (cachedResponse && self.useCache) {
58-
UIImage *i = [UIImage imageWithData:cachedResponse.data];
59-
if (i) {
60-
self.image = i;
61-
cacheHit = YES;
36+
self.task = [[NSURLSession sharedSession] dataTaskWithURL:self.imageURL completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
37+
if (data == nil) {
38+
ApptentiveLogError(@"Unable to download image at %@: %@", self.imageURL, error);
39+
self.task = nil;
40+
41+
if ([self.delegate respondsToSelector:@selector(networkImageView:didFailWithError:)]) {
42+
dispatch_async(dispatch_get_main_queue(), ^{
43+
[self.delegate networkImageView:self didFailWithError:error];
44+
});
45+
}
46+
} else {
47+
UIImage *newImage = [UIImage imageWithData:data];
48+
if (newImage) {
49+
dispatch_async(dispatch_get_main_queue(), ^{
50+
self.image = newImage;
51+
});
6252
}
6353
}
64-
}
54+
}];
6555

66-
if (!cacheHit) {
67-
self.connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
68-
[self.connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
69-
[self.connection start];
70-
}
56+
[self.task resume];
7157
}
7258
}
7359

@@ -78,52 +64,6 @@ - (void)setImageURL:(NSURL *)anImageURL {
7864
}
7965
}
8066

81-
#pragma mark NSURLConnectionDelegate
82-
- (void)connection:(NSURLConnection *)aConnection didFailWithError:(NSError *)error {
83-
if (aConnection == self.connection) {
84-
ApptentiveLogError(@"Unable to download image at %@: %@", self.imageURL, error);
85-
self.connection = nil;
86-
87-
if ([self.delegate respondsToSelector:@selector(networkImageView:didFailWithError:)]) {
88-
[self.delegate networkImageView:self didFailWithError:error];
89-
}
90-
}
91-
}
92-
93-
#pragma mark NSURLConnectionDataDelegate
94-
- (void)connection:(NSURLConnection *)aConnection didReceiveResponse:(NSURLResponse *)aResponse {
95-
if (aConnection == self.connection) {
96-
self.imageData = [[NSMutableData alloc] init];
97-
self.response = [aResponse copy];
98-
}
99-
}
100-
101-
- (void)connection:(NSURLConnection *)aConnection didReceiveData:(NSData *)data {
102-
if (aConnection == self.connection) {
103-
[self.imageData appendData:data];
104-
}
105-
}
106-
107-
- (void)connectionDidFinishLoading:(NSURLConnection *)aConnection {
108-
if (self.connection == aConnection) {
109-
UIImage *newImage = [UIImage imageWithData:self.imageData];
110-
if (newImage) {
111-
self.image = newImage;
112-
if (self.useCache) {
113-
NSURLRequest *request = [NSURLRequest requestWithURL:self.imageURL];
114-
NSURLCache *cache = [[Apptentive sharedConnection].backend imageCache];
115-
NSCachedURLResponse *cachedResponse = [[NSCachedURLResponse alloc] initWithResponse:self.response data:self.imageData userInfo:nil storagePolicy:NSURLCacheStorageAllowed];
116-
[cache storeCachedResponse:cachedResponse forRequest:request];
117-
cachedResponse = nil;
118-
119-
if ([self.delegate respondsToSelector:@selector(networkImageViewDidLoad:)]) {
120-
[self.delegate networkImageViewDidLoad:self];
121-
}
122-
}
123-
}
124-
}
125-
}
126-
12767
@end
12868

12969
NS_ASSUME_NONNULL_END

Apptentive/Apptentive/Engagement/Interactions/Notes/ApptentiveInteractionTextModalController.m

+2-12
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ - (void)presentInteractionFromViewController:(nullable UIViewController *)viewCo
5151

5252
#pragma mark UIAlertController
5353

54-
- (UIAlertController *)alertControllerWithInteraction:(ApptentiveInteraction *)interaction {
54+
- (nullable UIAlertController *)alertControllerWithInteraction:(ApptentiveInteraction *)interaction {
5555
NSDictionary *config = interaction.configuration;
5656
NSString *title = config[@"title"];
5757
NSString *message = config[@"body"];
@@ -61,17 +61,7 @@ - (UIAlertController *)alertControllerWithInteraction:(ApptentiveInteraction *)i
6161
return nil;
6262
}
6363

64-
NSString *layout = config[@"layout"];
65-
UIAlertControllerStyle preferredStyle;
66-
if ([layout isEqualToString:@"center"]) {
67-
preferredStyle = UIAlertControllerStyleAlert;
68-
} else if ([layout isEqualToString:@"bottom"]) {
69-
preferredStyle = UIAlertControllerStyleActionSheet;
70-
} else {
71-
preferredStyle = UIAlertControllerStyleAlert;
72-
}
73-
74-
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:preferredStyle];
64+
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
7565

7666
BOOL cancelActionAdded = NO;
7767
NSArray *actions = config[@"actions"];

Apptentive/Apptentive/Engagement/Model/ApptentiveConversation.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,15 @@ - (void)checkForDiffs {
206206
}
207207

208208
// See if any of the non-custom device attributes have changed
209-
[self.device updateWithCurrentDeviceValues];
210-
211209
[self checkForDeviceDiffs];
212210
}
213211
}
214212

215213
- (void)checkForDeviceDiffs {
216214
ApptentiveLogVerbose(ApptentiveLogTagConversation, @"Diffing device");
217215

216+
[self.device updateWithCurrentDeviceValues];
217+
218218
NSDictionary *deviceDiffs = [ApptentiveUtilities diffDictionary:self.device.JSONDictionary againstDictionary:self.lastSentDevice];
219219

220220
if (deviceDiffs.count > 0) {

Apptentive/Apptentive/Engagement/Model/ApptentiveConversationManager.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extern NSString *const ApptentiveConversationStateDidChangeNotificationKeyConver
4949

5050
- (BOOL)saveMetadata;
5151

52-
- (void)resume;
52+
- (void)completeHousekeepingTasks;
5353

5454
- (void)pause;
5555

Apptentive/Apptentive/Engagement/Model/ApptentiveConversationManager.m

+7-6
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,11 @@ - (nullable ApptentiveConversation *)loadConversation {
177177
}
178178
}
179179

180-
// any remaining conversations are 'logged out', and we should not load them.
181-
if (self.conversationMetadata.items.count > 0) {
180+
// The presence of a logged-out conversation means that we shouldn't start a new anonymous converstion or attempt to migrate a legacy conversation. No conversation should be active.
181+
item = [self.conversationMetadata findItemFilter:^BOOL(ApptentiveConversationMetadataItem *item) {
182+
return item.state == ApptentiveConversationStateLoggedOut;
183+
}];
184+
if (item != nil) {
182185
ApptentiveLogDebug(ApptentiveLogTagConversation, @"Can't load conversation: only 'logged-out' conversations available");
183186
return nil;
184187
}
@@ -204,7 +207,7 @@ - (nullable ApptentiveConversation *)loadConversation {
204207
return legacyConversation;
205208
}
206209

207-
// no conversation available: create a new one
210+
// no conversation available: create a new anonymous conversation
208211
ApptentiveLogDebug(ApptentiveLogTagConversation, @"Can't load conversation: creating anonymous conversation...");
209212
ApptentiveConversation *anonymousConversation = [[ApptentiveConversation alloc] initWithState:ApptentiveConversationStateAnonymousPending];
210213
[self fetchConversationToken:anonymousConversation];
@@ -979,11 +982,9 @@ - (NSString *)conversationContainerPathForDirectoryName:(NSString *)directoryNam
979982

980983
#pragma mark - Metadata
981984

982-
- (void)resume {
985+
- (void)completeHousekeepingTasks {
983986
[self updateManifestIfNeeded];
984987

985-
[self.activeConversation checkForDiffs];
986-
987988
[self.messageManager checkForMessages];
988989
}
989990

Apptentive/Apptentive/Engagement/Persistence/ApptentiveBackend+Engagement.m

+8-2
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,17 @@ - (BOOL)engageLocalEvent:(NSString *)event userInfo:(nullable NSDictionary *)use
9191
}
9292

9393
- (BOOL)engageCodePoint:(NSString *)codePoint fromInteraction:(nullable ApptentiveInteraction *)fromInteraction userInfo:(nullable NSDictionary *)userInfo customData:(nullable NSDictionary *)customData extendedData:(nullable NSArray *)extendedData fromViewController:(nullable UIViewController *)viewController {
94-
ApptentiveLogInfo(@"Engage Apptentive event: %@", codePoint);
95-
if (![self isReady]) {
94+
if (self.state != ApptentiveBackendStatePayloadDatabaseAvailable) {
95+
[self.operationQueue addOperationWithBlock:^{
96+
[self engageCodePoint:codePoint fromInteraction:fromInteraction userInfo:userInfo customData:customData extendedData:extendedData fromViewController:viewController];
97+
}];
98+
99+
ApptentiveLogInfo(@"Backend not ready. Deferring engagement of %@", codePoint);
96100
return NO;
97101
}
98102

103+
ApptentiveLogInfo(@"Engage Apptentive event: %@", codePoint);
104+
99105
// TODO: Do this on the background queue?
100106
ApptentiveConversation *conversation = self.conversationManager.activeConversation;
101107

0 commit comments

Comments
 (0)