Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
frankus committed Nov 7, 2017
2 parents d213894 + d0e4507 commit 729fab1
Show file tree
Hide file tree
Showing 52 changed files with 1,224 additions and 313 deletions.
24 changes: 20 additions & 4 deletions Apptentive/Apptentive.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@
EF8EE3A61EBA81880033E7A1 /* ATDataModel v5 to v6.xcmappingmodel in Sources */ = {isa = PBXBuildFile; fileRef = EF8EE3A21EBA79EC0033E7A1 /* ATDataModel v5 to v6.xcmappingmodel */; };
EF8EE3AB1EBBA5D00033E7A1 /* ApptentiveJWT.h in Headers */ = {isa = PBXBuildFile; fileRef = EF8EE3A91EBBA5D00033E7A1 /* ApptentiveJWT.h */; };
EF8EE3AC1EBBA5D00033E7A1 /* ApptentiveJWT.m in Sources */ = {isa = PBXBuildFile; fileRef = EF8EE3AA1EBBA5D00033E7A1 /* ApptentiveJWT.m */; };
EF9009901F8D370400DC5B56 /* ApptentiveLogMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = EF90098E1F8D370400DC5B56 /* ApptentiveLogMonitor.h */; };
EF9009911F8D370400DC5B56 /* ApptentiveLogMonitor.m in Sources */ = {isa = PBXBuildFile; fileRef = EF90098F1F8D370400DC5B56 /* ApptentiveLogMonitor.m */; };
EF9009941F8D64B800DC5B56 /* ApptentiveLogWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = EF9009921F8D64B800DC5B56 /* ApptentiveLogWriter.h */; };
EF9009951F8D64B800DC5B56 /* ApptentiveLogWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = EF9009931F8D64B800DC5B56 /* ApptentiveLogWriter.m */; };
EFC308D21EC52915006B6D36 /* ApptentiveStopWatch.h in Headers */ = {isa = PBXBuildFile; fileRef = EFC308D01EC52915006B6D36 /* ApptentiveStopWatch.h */; };
EFC308D31EC52915006B6D36 /* ApptentiveStopWatch.m in Sources */ = {isa = PBXBuildFile; fileRef = EFC308D11EC52915006B6D36 /* ApptentiveStopWatch.m */; };
EFC308D71ECA6692006B6D36 /* ApptentiveLegacyConversationRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = EFC308D51ECA6692006B6D36 /* ApptentiveLegacyConversationRequest.h */; };
Expand Down Expand Up @@ -807,6 +811,10 @@
EF8EE3A21EBA79EC0033E7A1 /* ATDataModel v5 to v6.xcmappingmodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcmappingmodel; path = "ATDataModel v5 to v6.xcmappingmodel"; sourceTree = "<group>"; };
EF8EE3A91EBBA5D00033E7A1 /* ApptentiveJWT.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApptentiveJWT.h; sourceTree = "<group>"; };
EF8EE3AA1EBBA5D00033E7A1 /* ApptentiveJWT.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApptentiveJWT.m; sourceTree = "<group>"; };
EF90098E1F8D370400DC5B56 /* ApptentiveLogMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApptentiveLogMonitor.h; sourceTree = "<group>"; };
EF90098F1F8D370400DC5B56 /* ApptentiveLogMonitor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApptentiveLogMonitor.m; sourceTree = "<group>"; };
EF9009921F8D64B800DC5B56 /* ApptentiveLogWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApptentiveLogWriter.h; sourceTree = "<group>"; };
EF9009931F8D64B800DC5B56 /* ApptentiveLogWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApptentiveLogWriter.m; sourceTree = "<group>"; };
EFC308D01EC52915006B6D36 /* ApptentiveStopWatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApptentiveStopWatch.h; sourceTree = "<group>"; };
EFC308D11EC52915006B6D36 /* ApptentiveStopWatch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApptentiveStopWatch.m; sourceTree = "<group>"; };
EFC308D51ECA6692006B6D36 /* ApptentiveLegacyConversationRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApptentiveLegacyConversationRequest.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1381,6 +1389,10 @@
EFF3FE3A1E8C2F05006AD2B4 /* ApptentiveLog.m */,
EFF3FE401E8C386E006AD2B4 /* ApptentiveLogTag.h */,
EFF3FE411E8C386E006AD2B4 /* ApptentiveLogTag.m */,
EF90098E1F8D370400DC5B56 /* ApptentiveLogMonitor.h */,
EF90098F1F8D370400DC5B56 /* ApptentiveLogMonitor.m */,
EF9009921F8D64B800DC5B56 /* ApptentiveLogWriter.h */,
EF9009931F8D64B800DC5B56 /* ApptentiveLogWriter.m */,
EF1812491E8084C80053BD68 /* ApptentiveSafeCollections.h */,
EF18124A1E8084C80053BD68 /* ApptentiveSafeCollections.m */,
EFC308D01EC52915006B6D36 /* ApptentiveStopWatch.h */,
Expand Down Expand Up @@ -1685,6 +1697,7 @@
EF8EE3981EB3F37B0033E7A1 /* ApptentiveConversationBaseRequest.h in Headers */,
01F1DFF81E5BBFBD009AB3D2 /* ApptentiveConversationMetadata.h in Headers */,
01A2D1AA1E490A9700C2103A /* ApptentiveAppConfiguration.h in Headers */,
EF9009901F8D370400DC5B56 /* ApptentiveLogMonitor.h in Headers */,
EF8EE3AB1EBBA5D00033E7A1 /* ApptentiveJWT.h in Headers */,
01A2D1D81E490A9700C2103A /* ApptentiveDataManager.h in Headers */,
01A2D0FF1E490A9700C2103A /* ApptentiveNetworkImageIconView.h in Headers */,
Expand Down Expand Up @@ -1770,6 +1783,7 @@
0140D6021E8354A9007B5130 /* ApptentiveMessageSender.h in Headers */,
014508A81EAABEDE003326E7 /* ApptentiveInteractionsRequest.h in Headers */,
014508A01EAAB26D003326E7 /* ApptentiveConversationRequest.h in Headers */,
EF9009941F8D64B800DC5B56 /* ApptentiveLogWriter.h in Headers */,
0140D60E1E83553C007B5130 /* ApptentiveLegacyMessageSender.h in Headers */,
01A2D1F21E490A9700C2103A /* ApptentiveSurveyMultilineCell.h in Headers */,
01A2D0FD1E490A9700C2103A /* ApptentiveHUDViewController.h in Headers */,
Expand Down Expand Up @@ -2037,6 +2051,7 @@
01A2D1441E490A9700C2103A /* ApptentiveBackend+Engagement.m in Sources */,
01A2D1F51E490A9700C2103A /* ApptentiveSurveyOtherCell.m in Sources */,
014508B21EAE5F71003326E7 /* ApptentiveClient.m in Sources */,
EF9009911F8D370400DC5B56 /* ApptentiveLogMonitor.m in Sources */,
0140D60D1E83553C007B5130 /* ApptentiveLegacyMessage.m in Sources */,
01A2D1B51E490A9700C2103A /* ApptentiveLegacySurveyResponse.m in Sources */,
01A2D1181E490A9700C2103A /* ApptentiveInteractionRatingDialogController.m in Sources */,
Expand Down Expand Up @@ -2133,6 +2148,7 @@
01A2D1061E490A9700C2103A /* ApptentiveUnreadMessagesBadgeView.m in Sources */,
01A2D11A1E490A9700C2103A /* ApptentiveInteractionSurveyController.m in Sources */,
0134EB1B1EA9930200DA4925 /* ApptentiveDevicePayload.m in Sources */,
EF9009951F8D64B800DC5B56 /* ApptentiveLogWriter.m in Sources */,
01A2D1241E490A9700C2103A /* ApptentiveCustomData.m in Sources */,
01A2D1E31E490A9700C2103A /* ApptentiveSurveyCollectionViewLayout.m in Sources */,
01A2D1BF1E490A9700C2103A /* ApptentiveRecord.m in Sources */,
Expand Down Expand Up @@ -2377,7 +2393,7 @@
GCC_PREPROCESSOR_DEFINITIONS = "APPTENTIVE_DEBUG=1";
INFOPLIST_FILE = Apptentive/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.apptentive.Apptentive;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -2397,7 +2413,7 @@
GCC_PREFIX_HEADER = "Apptentive/Misc/ApptentiveConnect-Prefix.pch";
INFOPLIST_FILE = Apptentive/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.apptentive.Apptentive;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -2448,7 +2464,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = ApptentiveDebugging/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.apptentive.ApptentiveDebugging;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -2467,7 +2483,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = ApptentiveDebugging/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.apptentive.ApptentiveDebugging;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
21 changes: 13 additions & 8 deletions Apptentive/Apptentive/Apptentive.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ FOUNDATION_EXPORT double ApptentiveVersionNumber;
FOUNDATION_EXPORT const unsigned char ApptentiveVersionString[];

/** The version number of the Apptentive SDK. */
#define kApptentiveVersionString @"4.0.7"
#define kApptentiveVersionString @"4.1.0"

/** The version number of the Apptentive API platform. */
#define kApptentiveAPIVersionString @"9"

/** The platform that the SDK is built for. */
#define kApptentivePlatformString @"iOS"
Expand Down Expand Up @@ -98,18 +101,20 @@ typedef NS_ENUM(NSInteger, ApptentivePushProvider) {
Log levels supported by the logging system. Each level includes those above it on the list.
*/
typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) {
/** Undefined. */
ApptentiveLogLevelUndefined = 0,
/** Critical failure log messages. */
ApptentiveLogLevelCrit = 0,
ApptentiveLogLevelCrit = 1,
/** Error log messages. */
ApptentiveLogLevelError = 1,
ApptentiveLogLevelError = 2,
/** Warning log messages. */
ApptentiveLogLevelWarn = 2,
ApptentiveLogLevelWarn = 3,
/** Informational log messages. */
ApptentiveLogLevelInfo = 3,
ApptentiveLogLevelInfo = 4,
/** Log messages that are potentially useful for debugging. */
ApptentiveLogLevelDebug = 4,
ApptentiveLogLevelDebug = 5,
/** All possible log messages enabled. */
ApptentiveLogLevelVerbose = 5
ApptentiveLogLevelVerbose = 6
};

/**
Expand Down Expand Up @@ -514,7 +519,7 @@ typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) {
*/

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

///-------------------------------------
/// @name Attach Text, Images, and Files
Expand Down
73 changes: 55 additions & 18 deletions Apptentive/Apptentive/Apptentive.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#import "ApptentiveMessageManager.h"
#import "ApptentiveMessageSender.h"
#import "ApptentiveAttachment.h"
#import "ApptentiveLogMonitor.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -40,12 +41,14 @@
NSNotificationName const ApptentiveInteractionsDidUpdateNotification = @"ApptentiveInteractionsDidUpdateNotification";
NSNotificationName const ApptentiveInteractionsShouldDismissNotification = @"ApptentiveInteractionsShouldDismissNotification";
NSNotificationName const ApptentiveConversationCreatedNotification = @"ApptentiveConversationCreatedNotification";
NSNotificationName const ApptentiveManifestRawDataDidReceiveNotification = @"ApptentiveManifestRawDataDidReceiveNotification";

NSString *const ApptentiveSurveyIDKey = @"ApptentiveSurveyIDKey";
NSString *const ApptentiveInteractionsShouldDismissAnimatedKey = @"ApptentiveInteractionsShouldDismissAnimatedKey";

NSString *const ApptentiveCustomDeviceDataPreferenceKey = @"ApptentiveCustomDeviceDataPreferenceKey";
NSString *const ApptentiveCustomPersonDataPreferenceKey = @"ApptentiveCustomPersonDataPreferenceKey";
NSString *const ApptentiveManifestRawDataKey = @"ApptentiveManifestRawDataKey";

NSString *const ApptentiveErrorDomain = @"com.apptentive";

Expand Down Expand Up @@ -108,12 +111,17 @@ - (id)initWithConfiguration:(ApptentiveConfiguration *)configuration {
self = [super init];

if (self) {
// it's important to set the log level first and the initialize log monitor
// otherwise the log monitor configuration would be overwritten by
// the SDK configuration
ApptentiveLogSetLevel(configuration.logLevel);

[ApptentiveLogMonitor tryInitializeWithBaseURL:configuration.baseURL appKey:configuration.apptentiveKey signature:configuration.apptentiveSignature];

_operationQueue = [[NSOperationQueue alloc] init];
_operationQueue.maxConcurrentOperationCount = 1;
_operationQueue.name = @"Apptentive Operation Queue";

ApptentiveLogSetLevel(configuration.logLevel);

_style = [[ApptentiveStyleSheet alloc] init];
_apptentiveKey = configuration.apptentiveKey;
_apptentiveSignature = configuration.apptentiveSignature;
Expand All @@ -129,6 +137,8 @@ - (id)initWithConfiguration:(ApptentiveConfiguration *)configuration {
[ApptentiveSDK setDistributionName:configuration.distributionName];
[ApptentiveSDK setDistributionVersion:[[ApptentiveVersion alloc] initWithString:configuration.distributionVersion]];
}

[self registerNotifications];

ApptentiveLogInfo(@"Apptentive SDK Version %@", [ApptentiveSDK SDKVersion].versionString);
}
Expand Down Expand Up @@ -738,22 +748,28 @@ - (void)fireLocalNotificationWithUserInfo:(NSDictionary *)userInfo {
NSDictionary *apptentiveUserInfo = @{ @"apptentive": userInfo[@"apptentive"] };
NSString *soundName = userInfo[@"apptentive"][@"sound"];

if ([UNUserNotificationCenter class] && [[UNUserNotificationCenter currentNotificationCenter].delegate respondsToSelector:@selector(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)]) {
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
content.title = title;
content.body = body;
content.userInfo = apptentiveUserInfo;
content.sound = [soundName isEqualToString:@"default"] ? [UNNotificationSound defaultSound] : [UNNotificationSound soundNamed:soundName];
if (@available(iOS 10.0, *)) {
if ([[UNUserNotificationCenter currentNotificationCenter].delegate respondsToSelector:@selector(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)]) {
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
content.title = title;
content.body = body;
content.userInfo = apptentiveUserInfo;
content.sound = [soundName isEqualToString:@"default"] ? [UNNotificationSound defaultSound] : [UNNotificationSound soundNamed:soundName];

UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:1 repeats:NO];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@"com.apptentive" content:content trigger:trigger];
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:1 repeats:NO];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@"com.apptentive" content:content trigger:trigger];

[UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
if (error) {
ApptentiveLogError(@"Error posting local notification: %@", error);
}
}];
} else if ([[UIApplication sharedApplication].delegate respondsToSelector:@selector(application:didReceiveLocalNotification:)]) {
[UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
if (error) {
ApptentiveLogError(@"Error posting local notification: %@", error);
}
}];

return;
}
}

if ([[UIApplication sharedApplication].delegate respondsToSelector:@selector(application:didReceiveLocalNotification:)]) {
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.alertTitle = title;
localNotification.alertBody = body;
Expand Down Expand Up @@ -890,6 +906,26 @@ - (void)setAuthenticationFailureCallback:(ApptentiveAuthenticationFailureCallbac
self.backend.authenticationFailureCallback = authenticationFailureCallback;
}

#pragma mark -
#pragma mark Notifications

- (void)registerNotifications {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForegroundNotification:) name:UIApplicationWillEnterForegroundNotification object:nil];
}

- (void)applicationWillEnterForegroundNotification:(NSNotification *)notification {
ApptentiveLogMonitor *logMonitor = [ApptentiveLogMonitor sharedInstance];
if (logMonitor) {
ApptentiveLogDebug(ApptentiveLogTagMonitor, @"Resuming log monitor...");
[logMonitor resume];
} else {
ApptentiveLogDebug(ApptentiveLogTagMonitor, @"Trying to initialize log monitor...");
[ApptentiveLogMonitor tryInitializeWithBaseURL:self.baseURL
appKey:self.apptentiveKey
signature:self.apptentiveSignature];
}
}

#pragma mark -
#pragma mark Logging System

Expand Down Expand Up @@ -933,8 +969,9 @@ @implementation ApptentiveNavigationController
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
if (!([UINavigationBar appearance].barTintColor || [UINavigationBar appearanceWhenContainedIn:[ApptentiveNavigationController class], nil].barTintColor)) {
[UINavigationBar appearanceWhenContainedIn:[ApptentiveNavigationController class], nil].barTintColor = [UIColor whiteColor];

if (!([UINavigationBar appearance].barTintColor || [UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[ [ApptentiveNavigationController class] ]].barTintColor)) {
[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[ [ApptentiveNavigationController class] ]].barTintColor = [UIColor whiteColor];
}
}
return self;
Expand Down
9 changes: 9 additions & 0 deletions Apptentive/Apptentive/ApptentiveStyleSheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface ApptentiveStyleSheet : NSObject <ApptentiveStyle>


/**
Creates a stylesheet by loading a property list from the specified file URL.
@param stylePropertyListURL A file URL pointing to a style sheet property list.
@return The newly-initialized style sheet, or nil if there was an error.
*/
- (nullable instancetype)initWithContentsOfURL:(NSURL *)stylePropertyListURL;

/// The font family to be used in the Apptentive UI
@property (copy, nonatomic) NSString *fontFamily;

Expand Down
Loading

0 comments on commit 729fab1

Please sign in to comment.