diff --git a/plugin.xml b/plugin.xml index 0cc6ffb..98acb2e 100644 --- a/plugin.xml +++ b/plugin.xml @@ -41,7 +41,7 @@ Cordova - 4.1.1 + 5.0.0 @@ -74,7 +74,7 @@ - 4.1.1 + 5.0.0 diff --git a/src/ios/.clang-format b/src/ios/.clang-format new file mode 100644 index 0000000..6906938 --- /dev/null +++ b/src/ios/.clang-format @@ -0,0 +1,71 @@ +--- +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +ConstructorInitializerIndentWidth: 4 + +AlignAfterOpenBracket: false +AlignEscapedNewlinesLeft: true +AlignOperands: false +AlignTrailingComments: true + +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: true +AllowShortIfStatementsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortLoopsOnASingleLine: true + +AlwaysBreakAfterDefinitionReturnType: false +AlwaysBreakTemplateDeclarations: false +AlwaysBreakBeforeMultilineStrings: false + +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: false + +BinPackArguments: true +BinPackParameters: true +ColumnLimit: 0 +ConstructorInitializerAllOnOneLineOrOnePerLine: true +DerivePointerAlignment: false +ExperimentalAutoDetectBinPacking: false +IndentCaseLabels: true +IndentWrappedFunctionNames: false +IndentFunctionDeclarationAfterType: false +MaxEmptyLinesToKeep: 2 +KeepEmptyLinesAtTheStartOfBlocks: false +NamespaceIndentation: Inner +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 10000 +PenaltyBreakComment: 300 +PenaltyBreakString: 10000 +PenaltyBreakFirstLessLess: 120 +PenaltyExcessCharacter: 1 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Right +SpacesBeforeTrailingComments: 1 +Cpp11BracedListStyle: true +Standard: Auto +IndentWidth: 4 +TabWidth: 4 +UseTab: Always +BreakBeforeBraces: Attach + +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpacesInAngles: false +SpaceInEmptyParentheses: false +SpacesInCStyleCastParentheses: false +SpaceAfterCStyleCast: false +SpacesInContainerLiterals: false +SpaceBeforeAssignmentOperators: true + +ContinuationIndentWidth: 4 +CommentPragmas: '^ IWYU pragma:' +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +SpaceBeforeParens: ControlStatements +DisableFormat: false +... diff --git a/src/ios/ApptentiveBridge.h b/src/ios/ApptentiveBridge.h old mode 100755 new mode 100644 index dac1834..e6637f3 --- a/src/ios/ApptentiveBridge.h +++ b/src/ios/ApptentiveBridge.h @@ -1,7 +1,8 @@ #import + @interface ApptentiveBridge : CDVPlugin -- (void)execute:(CDVInvokedUrlCommand*)command; +- (void)execute:(CDVInvokedUrlCommand *)command; -@end \ No newline at end of file +@end diff --git a/src/ios/ApptentiveBridge.m b/src/ios/ApptentiveBridge.m old mode 100755 new mode 100644 index ea87674..ab2b641 --- a/src/ios/ApptentiveBridge.m +++ b/src/ios/ApptentiveBridge.m @@ -3,403 +3,376 @@ #import "ApptentiveBridge.h" -@implementation ApptentiveBridge { - BOOL apptentiveInitted; - BOOL registeredForMessageNotifications; - NSString* messageNotificationCallback; +@implementation ApptentiveBridge { + BOOL apptentiveInitted; + BOOL registeredForMessageNotifications; + NSString *messageNotificationCallback; } -- (void)execute:(CDVInvokedUrlCommand*)command { - NSString* callbackId = [command callbackId]; - if ([command arguments].count == 0) { - [self sendFailureMessage:@"Insufficient arguments: No method name specified." callbackId:callbackId]; - return; - } - NSString* functionCall = [command argumentAtIndex:0]; - NSLog(@"Function call: %@",functionCall); - - //initialization - if ([functionCall isEqualToString:@"deviceReady"]) { - [self initAPIKey:callbackId]; - return; - } - if (!apptentiveInitted) { - [self sendFailureMessage:@"Apptentive API key is not set" callbackId:callbackId]; - return; - } - - //all other functions - if ([functionCall isEqualToString:@"addCustomDeviceData"]) { - [self addCustomDeviceData:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"addCustomPersonData"]) { - [self addCustomPersonData:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"engage"]) { - [self engage:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"openAppStore"]) { - [self openAppStore]; - } - else if ([functionCall isEqualToString:@"showMessageCenter"]) { - [self showMessageCenter:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"registerForMessageNotifications"]) { - [self registerForMessageNotifications:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"removeCustomDeviceData"]) { - [self removeCustomDeviceData:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"removeCustomPersonData"]) { - [self removeCustomPersonData:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"sendAttachmentFileWithMimeType"]) { - [self sendAttachmentFileWithMimeType:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"sendAttachmentImage"]) { - [self sendAttachmentImage:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"sendAttachmentText"]) { - [self sendAttachmentText:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"setProperty"]) { - [self setProperty:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"getProperty"]) { - [self getProperty:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"unreadMessageCount"]) { - [self unreadMessageCount:callbackId]; - } - else if ([functionCall isEqualToString:@"unregisterForNotifications"]) { - [self unregisterForNotifications]; - } - else if ([functionCall isEqualToString:@"canShowInteraction"]) { - [self canShowInteraction:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"canShowMessageCenter"]) { - [self canShowMessageCenter:callbackId]; - } - else if ([functionCall isEqualToString:@"login"]) { - [self login:[command arguments] callBackString:callbackId]; - } - else if ([functionCall isEqualToString:@"logout"]) { - [self logoutWithCallBackString:callbackId]; - } - else { - //command not recognized - [self sendFailureMessage:@"Command not recognized" callbackId:callbackId]; - } - +- (void)execute:(CDVInvokedUrlCommand *)command { + NSString *callbackId = [command callbackId]; + if ([command arguments].count == 0) { + [self sendFailureMessage:@"Insufficient arguments: No method name specified." callbackId:callbackId]; + return; + } + NSString *functionCall = [command argumentAtIndex:0]; + NSLog(@"Function call: %@", functionCall); + + //initialization + if ([functionCall isEqualToString:@"deviceReady"]) { + [self initAPIKey:callbackId]; + return; + } + if (!apptentiveInitted) { + [self sendFailureMessage:@"Apptentive API key is not set" callbackId:callbackId]; + return; + } + + //all other functions + if ([functionCall isEqualToString:@"addCustomDeviceData"]) { + [self addCustomDeviceData:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"addCustomPersonData"]) { + [self addCustomPersonData:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"engage"]) { + [self engage:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"openAppStore"]) { + [self openAppStore]; + } else if ([functionCall isEqualToString:@"showMessageCenter"]) { + [self showMessageCenter:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"registerForMessageNotifications"]) { + [self registerForMessageNotifications:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"removeCustomDeviceData"]) { + [self removeCustomDeviceData:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"removeCustomPersonData"]) { + [self removeCustomPersonData:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"sendAttachmentFileWithMimeType"]) { + [self sendAttachmentFileWithMimeType:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"sendAttachmentImage"]) { + [self sendAttachmentImage:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"sendAttachmentText"]) { + [self sendAttachmentText:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"setProperty"]) { + [self setProperty:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"getProperty"]) { + [self getProperty:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"unreadMessageCount"]) { + [self unreadMessageCount:callbackId]; + } else if ([functionCall isEqualToString:@"unregisterForNotifications"]) { + [self unregisterForNotifications]; + } else if ([functionCall isEqualToString:@"canShowInteraction"]) { + [self canShowInteraction:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"canShowMessageCenter"]) { + [self canShowMessageCenter:callbackId]; + } else if ([functionCall isEqualToString:@"login"]) { + [self login:[command arguments] callBackString:callbackId]; + } else if ([functionCall isEqualToString:@"logout"]) { + [self logoutWithCallBackString:callbackId]; + } else { + //command not recognized + [self sendFailureMessage:@"Command not recognized" callbackId:callbackId]; + } } -- (void)sendSuccessMessage:(NSString*)msg callbackId:(NSString *)callbackId { - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:msg]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; +- (void)sendSuccessMessage:(NSString *)msg callbackId:(NSString *)callbackId { + CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:msg]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; } -- (void)sendFailureMessage:(NSString*)error callbackId:(NSString *)callbackId { - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; +- (void)sendFailureMessage:(NSString *)error callbackId:(NSString *)callbackId { + CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; } -- (BOOL)parseBoolValue:(NSString*)value { - if ([value isEqualToString:@"true"] || [value isEqualToString:@"True"] || [value isEqualToString:@"yes"]) { - return YES; - } - else - return [value boolValue]; +- (BOOL)parseBoolValue:(NSString *)value { + if ([value isEqualToString:@"true"] || [value isEqualToString:@"True"] || [value isEqualToString:@"yes"]) { + return YES; + } else + return [value boolValue]; } -- (NSDictionary*)parseDictionaryFromString:(id)value { - NSDictionary *data; - if ([value isKindOfClass:[NSDictionary class]]) { - data = value; - } - else { - //custom data needs to be parsed to NSDictionary - assuming json was passed - NSData* data = [value dataUsingEncoding:NSUTF8StringEncoding]; - NSError *localError = nil; - data = [NSJSONSerialization JSONObjectWithData:data options:0 error:&localError]; - } - if (data != nil) { - return data; - } - else - return nil; +- (NSDictionary *)parseDictionaryFromString:(id)value { + NSDictionary *data; + if ([value isKindOfClass:[NSDictionary class]]) { + data = value; + } else { + //custom data needs to be parsed to NSDictionary - assuming json was passed + NSData *data = [value dataUsingEncoding:NSUTF8StringEncoding]; + NSError *localError = nil; + data = [NSJSONSerialization JSONObjectWithData:data options:0 error:&localError]; + } + if (data != nil) { + return data; + } else + return nil; } #pragma mark Initialization and Events -- (void)initAPIKey:(NSString*)callbackId { - // Access Info.plist for ApptentiveAPIKey - NSDictionary *infoPlist = [[NSBundle mainBundle] infoDictionary]; - NSString *apptentiveKey = [infoPlist objectForKey:@"ApptentiveKey"]; - NSString *apptentiveSignature = [infoPlist objectForKey:@"ApptentiveSignature"]; - NSString *pluginVersion = [infoPlist objectForKey:@"ApptentivePluginVersion"]; - - // FIXME: Do we really want to be logging this? - NSLog(@"Initializing Apptentive Apptentive App Key: %@, Apptentive App Signature: %@", apptentiveKey, apptentiveSignature); - - if (apptentiveKey.length == 0 || apptentiveSignature.length == 0) { - [self sendFailureMessage:@"Insufficient arguments - no API key." callbackId:callbackId]; - return; - } - ApptentiveConfiguration *configuration = [ApptentiveConfiguration configurationWithApptentiveKey:apptentiveKey apptentiveSignature:apptentiveSignature]; - configuration.distributionName = @"Cordova"; - configuration.distributionVersion = pluginVersion; - - [Apptentive registerWithConfiguration:configuration]; - apptentiveInitted = YES; - - NSURL *styleSheetURL = [[NSBundle mainBundle] URLForResource:@"ApptentiveStyles" withExtension:@"plist"]; - if (styleSheetURL != nil) { - Apptentive.shared.styleSheet = [[ApptentiveStyleSheet alloc] initWithContentsOfURL:styleSheetURL]; - } +- (void)initAPIKey:(NSString *)callbackId { + // Access Info.plist for ApptentiveAPIKey + NSDictionary *infoPlist = [[NSBundle mainBundle] infoDictionary]; + NSString *apptentiveKey = [infoPlist objectForKey:@"ApptentiveKey"]; + NSString *apptentiveSignature = [infoPlist objectForKey:@"ApptentiveSignature"]; + NSString *pluginVersion = [infoPlist objectForKey:@"ApptentivePluginVersion"]; + + // FIXME: Do we really want to be logging this? + NSLog(@"Initializing Apptentive Apptentive App Key: %@, Apptentive App Signature: %@", apptentiveKey, apptentiveSignature); + + if (apptentiveKey.length == 0 || apptentiveSignature.length == 0) { + [self sendFailureMessage:@"Insufficient arguments - no API key." callbackId:callbackId]; + return; + } + ApptentiveConfiguration *configuration = [ApptentiveConfiguration configurationWithApptentiveKey:apptentiveKey apptentiveSignature:apptentiveSignature]; + configuration.distributionName = @"Cordova"; + configuration.distributionVersion = pluginVersion; + + [Apptentive registerWithConfiguration:configuration]; + apptentiveInitted = YES; + + NSURL *styleSheetURL = [[NSBundle mainBundle] URLForResource:@"ApptentiveStyles" withExtension:@"plist"]; + if (styleSheetURL != nil) { + Apptentive.shared.styleSheet = [[ApptentiveStyleSheet alloc] initWithContentsOfURL:styleSheetURL]; + } } -- (void) registerForMessageNotifications:(NSArray*)arguments callBackString:(NSString*)callbackId { - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(unreadMessageCountChanged:) name:ApptentiveMessageCenterUnreadCountChangedNotification object:nil]; - registeredForMessageNotifications = YES; - messageNotificationCallback = callbackId; +- (void)registerForMessageNotifications:(NSArray *)arguments callBackString:(NSString *)callbackId { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(unreadMessageCountChanged:) name:ApptentiveMessageCenterUnreadCountChangedNotification object:nil]; + registeredForMessageNotifications = YES; + messageNotificationCallback = callbackId; } -- (void) unregisterForNotifications { - if (registeredForMessageNotifications) { - [[NSNotificationCenter defaultCenter] removeObserver:self name:ApptentiveMessageCenterUnreadCountChangedNotification object:nil]; - registeredForMessageNotifications = NO; - messageNotificationCallback = nil; - } +- (void)unregisterForNotifications { + if (registeredForMessageNotifications) { + [[NSNotificationCenter defaultCenter] removeObserver:self name:ApptentiveMessageCenterUnreadCountChangedNotification object:nil]; + registeredForMessageNotifications = NO; + messageNotificationCallback = nil; + } } #pragma mark Notifications - (void)unreadMessageCountChanged:(NSNotification *)notification { - // Unread message count is contained in the notification's userInfo dictionary. - NSNumber *unreadMessageCount = [notification.userInfo objectForKey:@"count"]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:[unreadMessageCount intValue]]; - [result setKeepCallback:[NSNumber numberWithBool:YES]]; - [self.commandDelegate sendPluginResult:result callbackId:messageNotificationCallback]; + // Unread message count is contained in the notification's userInfo dictionary. + NSNumber *unreadMessageCount = [notification.userInfo objectForKey:@"count"]; + CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:[unreadMessageCount intValue]]; + [result setKeepCallback:[NSNumber numberWithBool:YES]]; + [self.commandDelegate sendPluginResult:result callbackId:messageNotificationCallback]; } #pragma mark Properties and Interface Customization -- (void) setProperty:(NSArray*)arguments callBackString:(NSString*)callbackId { - if (arguments.count < 3) { - [self sendFailureMessage:@"Insufficient arguments for setting property" callbackId:callbackId]; - return; - } - NSString *property_id = [arguments objectAtIndex:1]; - NSString *value = [arguments objectAtIndex:2]; - if ([property_id isEqualToString:@"appID"]) { - [Apptentive sharedConnection].appID = value; - } - else if ([property_id isEqualToString:@"personName"]) { - [Apptentive sharedConnection].personName = value; - } - else if ([property_id isEqualToString:@"personEmailAddress"]) { - [Apptentive sharedConnection].personEmailAddress = value; - } - else { - [self sendFailureMessage:@"Property name not recognized" callbackId:callbackId]; - } +- (void)setProperty:(NSArray *)arguments callBackString:(NSString *)callbackId { + if (arguments.count < 3) { + [self sendFailureMessage:@"Insufficient arguments for setting property" callbackId:callbackId]; + return; + } + NSString *property_id = [arguments objectAtIndex:1]; + NSString *value = [arguments objectAtIndex:2]; + if ([property_id isEqualToString:@"appID"]) { + [Apptentive sharedConnection].appID = value; + } else if ([property_id isEqualToString:@"personName"]) { + [Apptentive sharedConnection].personName = value; + } else if ([property_id isEqualToString:@"personEmailAddress"]) { + [Apptentive sharedConnection].personEmailAddress = value; + } else { + [self sendFailureMessage:@"Property name not recognized" callbackId:callbackId]; + } } -- (void) getProperty:(NSArray*)arguments callBackString:(NSString*)callbackId { - if (arguments.count < 2) { - [self sendFailureMessage:@"Insufficient arguments for getting property" callbackId:callbackId]; - return; - } - NSString *property_id = [arguments objectAtIndex:1]; - NSString *value = nil; - if ([property_id isEqualToString:@"appID"]) { - value = [Apptentive sharedConnection].appID; - } - else if ([property_id isEqualToString:@"personName"]) { - value = [Apptentive sharedConnection].personName; - } - else if ([property_id isEqualToString:@"personEmailAddress"]) { - value = [Apptentive sharedConnection].personEmailAddress; - } - else { - [self sendFailureMessage:@"Property name not recognized" callbackId:callbackId]; - return; - } - - [self sendSuccessMessage:value callbackId:callbackId]; +- (void)getProperty:(NSArray *)arguments callBackString:(NSString *)callbackId { + if (arguments.count < 2) { + [self sendFailureMessage:@"Insufficient arguments for getting property" callbackId:callbackId]; + return; + } + NSString *property_id = [arguments objectAtIndex:1]; + NSString *value = nil; + if ([property_id isEqualToString:@"appID"]) { + value = [Apptentive sharedConnection].appID; + } else if ([property_id isEqualToString:@"personName"]) { + value = [Apptentive sharedConnection].personName; + } else if ([property_id isEqualToString:@"personEmailAddress"]) { + value = [Apptentive sharedConnection].personEmailAddress; + } else { + [self sendFailureMessage:@"Property name not recognized" callbackId:callbackId]; + return; + } + + [self sendSuccessMessage:value callbackId:callbackId]; } #pragma mark Methods -- (void) addCustomDeviceData:(NSArray*)arguments callBackString:(NSString*)callbackId { - NSString* key = [arguments objectAtIndex:1]; - id value = [arguments objectAtIndex:2]; - if ([value isKindOfClass:[NSString class]]) { - NSString* stringData = value; - [[Apptentive sharedConnection] addCustomDeviceDataString:stringData withKey:key]; - } - else if ([value isKindOfClass:[NSNumber class]] ) { - if (value == [NSNumber numberWithBool:YES] || value == [NSNumber numberWithBool:NO]) { - NSNumber* boolData = value; - [[Apptentive sharedConnection] addCustomDeviceDataBool:boolData.boolValue withKey:key]; - } else { - NSNumber* numberData = value; - [[Apptentive sharedConnection] addCustomDeviceDataNumber:numberData withKey:key]; - } - } else { - [self sendFailureMessage:@"Custom Device data type not recognized" callbackId:callbackId]; - return; - } - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; +- (void)addCustomDeviceData:(NSArray *)arguments callBackString:(NSString *)callbackId { + NSString *key = [arguments objectAtIndex:1]; + id value = [arguments objectAtIndex:2]; + if ([value isKindOfClass:[NSString class]]) { + NSString *stringData = value; + [[Apptentive sharedConnection] addCustomDeviceDataString:stringData withKey:key]; + } else if ([value isKindOfClass:[NSNumber class]]) { + if (value == [NSNumber numberWithBool:YES] || value == [NSNumber numberWithBool:NO]) { + NSNumber *boolData = value; + [[Apptentive sharedConnection] addCustomDeviceDataBool:boolData.boolValue withKey:key]; + } else { + NSNumber *numberData = value; + [[Apptentive sharedConnection] addCustomDeviceDataNumber:numberData withKey:key]; + } + } else { + [self sendFailureMessage:@"Custom Device data type not recognized" callbackId:callbackId]; + return; + } + CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; } -- (void) addCustomPersonData:(NSArray*)arguments callBackString:(NSString*)callbackId { - NSString* key = [arguments objectAtIndex:1]; - id value = [arguments objectAtIndex:2]; - if ([value isKindOfClass:[NSString class]]) { - NSString* stringData = value; - [[Apptentive sharedConnection] addCustomPersonDataString:stringData withKey:key]; - } - else if ([value isKindOfClass:[NSNumber class]] ) { - if (value == [NSNumber numberWithBool:YES] || value == [NSNumber numberWithBool:NO]) { - NSNumber* boolData = value; - [[Apptentive sharedConnection] addCustomPersonDataBool:boolData.boolValue withKey:key]; - } else { - NSNumber* numberData = value; - [[Apptentive sharedConnection] addCustomPersonDataNumber:numberData withKey:key]; - } - } else { - [self sendFailureMessage:@"Custom Person data type not recognized" callbackId:callbackId]; - return; - } - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; +- (void)addCustomPersonData:(NSArray *)arguments callBackString:(NSString *)callbackId { + NSString *key = [arguments objectAtIndex:1]; + id value = [arguments objectAtIndex:2]; + if ([value isKindOfClass:[NSString class]]) { + NSString *stringData = value; + [[Apptentive sharedConnection] addCustomPersonDataString:stringData withKey:key]; + } else if ([value isKindOfClass:[NSNumber class]]) { + if (value == [NSNumber numberWithBool:YES] || value == [NSNumber numberWithBool:NO]) { + NSNumber *boolData = value; + [[Apptentive sharedConnection] addCustomPersonDataBool:boolData.boolValue withKey:key]; + } else { + NSNumber *numberData = value; + [[Apptentive sharedConnection] addCustomPersonDataNumber:numberData withKey:key]; + } + } else { + [self sendFailureMessage:@"Custom Person data type not recognized" callbackId:callbackId]; + return; + } + CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; } -- (void)engage:(NSArray*)arguments callBackString:(NSString*)callbackId { - NSString* eventLabel = [arguments objectAtIndex:1]; - if([eventLabel isEqual:[NSNull null]]) { - [self sendFailureMessage:@"Insufficient arguments to call engage - label is null" callbackId:callbackId]; - return; - } - BOOL shown = false; - if (arguments.count == 2) { - shown = [[Apptentive sharedConnection] engage:eventLabel fromViewController:self.viewController]; - } - else if (arguments.count == 3) { - NSDictionary *customData = [self parseDictionaryFromString:[arguments objectAtIndex:2]]; - if (customData == nil) { - [self sendFailureMessage:@"Improperly formed json or object for engage custom data" callbackId:callbackId]; - return; - } - shown = [[Apptentive sharedConnection] engage:eventLabel withCustomData:customData fromViewController:self.viewController]; - } - CDVPluginResult* result = [CDVPluginResult - resultWithStatus:CDVCommandStatus_OK - messageAsBool:shown]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; +- (void)engage:(NSArray *)arguments callBackString:(NSString *)callbackId { + NSString *eventLabel = [arguments objectAtIndex:1]; + if ([eventLabel isEqual:[NSNull null]]) { + [self sendFailureMessage:@"Insufficient arguments to call engage - label is null" callbackId:callbackId]; + return; + } + + void (^completion)(BOOL) = ^void(BOOL shown) { + CDVPluginResult *result = [CDVPluginResult + resultWithStatus:CDVCommandStatus_OK + messageAsBool:shown]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; + }; + + if (arguments.count == 2) { + [Apptentive.shared engage:eventLabel fromViewController:self.viewController completion:completion]; + return; + } else if (arguments.count == 3) { + NSDictionary *customData = [self parseDictionaryFromString:[arguments objectAtIndex:2]]; + if (customData == nil) { + [self sendFailureMessage:@"Improperly formed json or object for engage custom data" callbackId:callbackId]; + return; + } + [Apptentive.shared engage:eventLabel withCustomData:customData fromViewController:self.viewController completion:completion]; + return; + } + + [self sendFailureMessage:@"Too many arguments" callbackId:callbackId]; } -- (void) openAppStore { - [[Apptentive sharedConnection] openAppStore]; +- (void)openAppStore { + [[Apptentive sharedConnection] openAppStore]; } -- (void) showMessageCenter:(NSArray*)arguments callBackString:(NSString*)callbackId { - if (arguments.count == 2) { - NSDictionary *customData = [self parseDictionaryFromString:[arguments objectAtIndex:1]]; - [[Apptentive sharedConnection] presentMessageCenterFromViewController:self.viewController withCustomData:customData]; - } else { - [[Apptentive sharedConnection] presentMessageCenterFromViewController:self.viewController]; - } +- (void)showMessageCenter:(NSArray *)arguments callBackString:(NSString *)callbackId { + if (arguments.count == 2) { + NSDictionary *customData = [self parseDictionaryFromString:[arguments objectAtIndex:1]]; + [[Apptentive sharedConnection] presentMessageCenterFromViewController:self.viewController withCustomData:customData]; + } else { + [[Apptentive sharedConnection] presentMessageCenterFromViewController:self.viewController]; + } } -- (void) removeCustomDeviceData:(NSArray*)arguments callBackString:(NSString*)callbackId { - NSString* key = [arguments objectAtIndex:1]; - [[Apptentive sharedConnection] removeCustomDeviceDataWithKey:key]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; +- (void)removeCustomDeviceData:(NSArray *)arguments callBackString:(NSString *)callbackId { + NSString *key = [arguments objectAtIndex:1]; + [[Apptentive sharedConnection] removeCustomDeviceDataWithKey:key]; + CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; } -- (void) removeCustomPersonData:(NSArray*)arguments callBackString:(NSString*)callbackId { - NSString* key = [arguments objectAtIndex:1]; - [[Apptentive sharedConnection] removeCustomPersonDataWithKey:key]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; +- (void)removeCustomPersonData:(NSArray *)arguments callBackString:(NSString *)callbackId { + NSString *key = [arguments objectAtIndex:1]; + [[Apptentive sharedConnection] removeCustomPersonDataWithKey:key]; + CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; } -- (void) sendAttachmentFileWithMimeType:(NSArray*)arguments callBackString:(NSString*)callbackId { - NSData* data = [[arguments objectAtIndex:1] dataUsingEncoding:NSUTF8StringEncoding]; - NSString* mimeType = [arguments objectAtIndex:2]; - [[Apptentive sharedConnection] sendAttachmentFile:data withMimeType:mimeType]; +- (void)sendAttachmentFileWithMimeType:(NSArray *)arguments callBackString:(NSString *)callbackId { + NSData *data = [[arguments objectAtIndex:1] dataUsingEncoding:NSUTF8StringEncoding]; + NSString *mimeType = [arguments objectAtIndex:2]; + [[Apptentive sharedConnection] sendAttachmentFile:data withMimeType:mimeType]; } -- (void) sendAttachmentImage:(NSArray*)arguments callBackString:(NSString*)callbackId { - //expecting Base64 encoded string data here - NSString* base64String = [arguments objectAtIndex:1]; - NSData* data = [[NSData alloc] initWithBase64EncodedString:base64String options:0]; - UIImage* attachmentImage = [UIImage imageWithData:data]; - if (attachmentImage == nil) { - [self sendFailureMessage:@"Image could not be constructed from the passed data" callbackId:callbackId]; - } - [[Apptentive sharedConnection] sendAttachmentImage:attachmentImage]; +- (void)sendAttachmentImage:(NSArray *)arguments callBackString:(NSString *)callbackId { + //expecting Base64 encoded string data here + NSString *base64String = [arguments objectAtIndex:1]; + NSData *data = [[NSData alloc] initWithBase64EncodedString:base64String options:0]; + UIImage *attachmentImage = [UIImage imageWithData:data]; + if (attachmentImage == nil) { + [self sendFailureMessage:@"Image could not be constructed from the passed data" callbackId:callbackId]; + } + [[Apptentive sharedConnection] sendAttachmentImage:attachmentImage]; } -- (void) sendAttachmentText:(NSArray*)arguments callBackString:(NSString*)callbackId { - NSString* text = [arguments objectAtIndex:1]; - [[Apptentive sharedConnection] sendAttachmentText:text]; +- (void)sendAttachmentText:(NSArray *)arguments callBackString:(NSString *)callbackId { + NSString *text = [arguments objectAtIndex:1]; + [[Apptentive sharedConnection] sendAttachmentText:text]; } -- (void) unreadMessageCount:(NSString*)callbackId { - NSUInteger unreadMessageCount = [[Apptentive sharedConnection] unreadMessageCount]; - CDVPluginResult* result = [CDVPluginResult - resultWithStatus:CDVCommandStatus_OK - messageAsInt:(int)unreadMessageCount]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; +- (void)unreadMessageCount:(NSString *)callbackId { + NSUInteger unreadMessageCount = [[Apptentive sharedConnection] unreadMessageCount]; + CDVPluginResult *result = [CDVPluginResult + resultWithStatus:CDVCommandStatus_OK + messageAsInt:(int)unreadMessageCount]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; } -- (void)canShowInteraction:(NSArray*)arguments callBackString:(NSString*)callbackId { - NSString* eventName = [arguments objectAtIndex:1]; - if([eventName isEqual:[NSNull null]]) { - [self sendFailureMessage:@"Insufficient arguments to call willShowInteraction - eventName is null" callbackId:callbackId]; - return; - } - BOOL canShow = [[Apptentive sharedConnection] canShowInteractionForEvent:eventName]; - CDVPluginResult* result = [CDVPluginResult - resultWithStatus:CDVCommandStatus_OK - messageAsBool:canShow]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; +- (void)canShowInteraction:(NSArray *)arguments callBackString:(NSString *)callbackId { + NSString *eventName = [arguments objectAtIndex:1]; + if ([eventName isEqual:[NSNull null]]) { + [self sendFailureMessage:@"Insufficient arguments to call willShowInteraction - eventName is null" callbackId:callbackId]; + return; + } + [Apptentive.shared queryCanShowInteractionForEvent:eventName completion:^(BOOL canShow) { + CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:canShow]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; + }]; } - (void)canShowMessageCenter:(NSString *)callbackId { - BOOL canShow = [[Apptentive sharedConnection] canShowMessageCenter]; - CDVPluginResult* result = [CDVPluginResult - resultWithStatus:CDVCommandStatus_OK - messageAsBool:canShow]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; + [Apptentive.shared queryCanShowMessageCenterWithCompletion:^(BOOL canShow) { + CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:canShow]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; + }]; } -- (void)login:(NSArray*)arguments callBackString:(NSString*)callbackId { - NSString* token = [arguments objectAtIndex:1]; - if([token isEqual:[NSNull null]]) { - [self sendFailureMessage:@"Insufficient arguments to call login - token is nil" callbackId:callbackId]; - return; - } - [[Apptentive shared] logInWithToken:token completion:^(BOOL success, NSError * _Nonnull error) { - CDVPluginResult* result; - if (success) { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - } else { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; - } - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; - }]; +- (void)login:(NSArray *)arguments callBackString:(NSString *)callbackId { + NSString *token = [arguments objectAtIndex:1]; + if ([token isEqual:[NSNull null]]) { + [self sendFailureMessage:@"Insufficient arguments to call login - token is nil" callbackId:callbackId]; + return; + } + [[Apptentive shared] logInWithToken:token completion:^(BOOL success, NSError *_Nonnull error) { + CDVPluginResult *result; + if (success) { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + } else { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; + } + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; + }]; } -- (void)logoutWithCallBackString:(NSString*)callbackId { - [[Apptentive shared] logOut]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; +- (void)logoutWithCallBackString:(NSString *)callbackId { + [[Apptentive shared] logOut]; + CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; } @end diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/ATDataModel.momd/ATDataModel 6.omo b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/ATDataModel.momd/ATDataModel 6.omo index 05f23e2..9047b32 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/ATDataModel.momd/ATDataModel 6.omo and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/ATDataModel.momd/ATDataModel 6.omo differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/0Su-Sq-q29-view-f2T-ot-d9N.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/0Su-Sq-q29-view-f2T-ot-d9N.nib/objects-11.0+.nib index b57a33c..7074371 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/0Su-Sq-q29-view-f2T-ot-d9N.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/0Su-Sq-q29-view-f2T-ot-d9N.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/0Su-Sq-q29-view-f2T-ot-d9N.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/0Su-Sq-q29-view-f2T-ot-d9N.nib/runtime.nib index e54d64a..8ce879d 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/0Su-Sq-q29-view-f2T-ot-d9N.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/0Su-Sq-q29-view-f2T-ot-d9N.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/98M-gg-3nj-view-yHY-Np-JOn.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/98M-gg-3nj-view-yHY-Np-JOn.nib/objects-11.0+.nib index d9e19b7..0274d2b 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/98M-gg-3nj-view-yHY-Np-JOn.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/98M-gg-3nj-view-yHY-Np-JOn.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/98M-gg-3nj-view-yHY-Np-JOn.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/98M-gg-3nj-view-yHY-Np-JOn.nib/runtime.nib index bd6438a..9ea6d82 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/98M-gg-3nj-view-yHY-Np-JOn.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/98M-gg-3nj-view-yHY-Np-JOn.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/About.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/About.nib/objects-11.0+.nib index 7e6a584..f32491e 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/About.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/About.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/About.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/About.nib/runtime.nib index 8176246..85fb799 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/About.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/About.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Banner.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Banner.nib/objects-11.0+.nib index 06842ed..c987172 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Banner.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Banner.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Banner.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Banner.nib/runtime.nib index 940bb2f..16b3921 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Banner.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Banner.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Info.plist b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Info.plist index 01d29a7..16cffda 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Info.plist and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Info.plist differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenter.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenter.nib/objects-11.0+.nib index d83184d..3091eef 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenter.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenter.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenter.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenter.nib/runtime.nib index a703319..1864d2f 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenter.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenter.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenterNavigation.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenterNavigation.nib/objects-11.0+.nib index dcdcdc3..682b625 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenterNavigation.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenterNavigation.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenterNavigation.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenterNavigation.nib/runtime.nib index 35b32d1..2c5723f 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenterNavigation.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/MessageCenterNavigation.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/NoPayloadNavigation.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/NoPayloadNavigation.nib/objects-11.0+.nib index 6b4bd94..8b0811b 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/NoPayloadNavigation.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/NoPayloadNavigation.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/NoPayloadNavigation.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/NoPayloadNavigation.nib/runtime.nib index fb95373..d2c0a11 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/NoPayloadNavigation.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/NoPayloadNavigation.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/SurveyNavigation.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/SurveyNavigation.nib/objects-11.0+.nib index e757e7c..5129fc3 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/SurveyNavigation.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/SurveyNavigation.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/SurveyNavigation.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/SurveyNavigation.nib/runtime.nib index 9e3befb..b1c08d0 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/SurveyNavigation.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/SurveyNavigation.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessage.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessage.nib/objects-11.0+.nib index 82db3c6..3069b83 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessage.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessage.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessage.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessage.nib/runtime.nib index 67a8667..983bdb1 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessage.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessage.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessageNavigation.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessageNavigation.nib/objects-11.0+.nib index 61171b8..c29ceda 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessageNavigation.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessageNavigation.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessageNavigation.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessageNavigation.nib/runtime.nib index e6d7e5f..a9d9295 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessageNavigation.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/UpgradeMessageNavigation.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Vhy-th-mTJ-view-RoE-zy-OMj.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Vhy-th-mTJ-view-RoE-zy-OMj.nib/objects-11.0+.nib index d4d7295..3ca4ec5 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Vhy-th-mTJ-view-RoE-zy-OMj.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Vhy-th-mTJ-view-RoE-zy-OMj.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Vhy-th-mTJ-view-RoE-zy-OMj.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Vhy-th-mTJ-view-RoE-zy-OMj.nib/runtime.nib index 54b61e4..602c728 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Vhy-th-mTJ-view-RoE-zy-OMj.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/Vhy-th-mTJ-view-RoE-zy-OMj.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/W0l-Dy-ioE-view-IzQ-h6-djc.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/W0l-Dy-ioE-view-IzQ-h6-djc.nib/objects-11.0+.nib index 340fe17..e47c562 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/W0l-Dy-ioE-view-IzQ-h6-djc.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/W0l-Dy-ioE-view-IzQ-h6-djc.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/W0l-Dy-ioE-view-IzQ-h6-djc.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/W0l-Dy-ioE-view-IzQ-h6-djc.nib/runtime.nib index c067cab..a5a4f9e 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/W0l-Dy-ioE-view-IzQ-h6-djc.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/W0l-Dy-ioE-view-IzQ-h6-djc.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/WnK-TF-euS-view-b8z-vy-rbq.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/WnK-TF-euS-view-b8z-vy-rbq.nib/objects-11.0+.nib index 9a27552..606bf42 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/WnK-TF-euS-view-b8z-vy-rbq.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/WnK-TF-euS-view-b8z-vy-rbq.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/WnK-TF-euS-view-b8z-vy-rbq.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/WnK-TF-euS-view-b8z-vy-rbq.nib/runtime.nib index c81e1f5..f57ce5c 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/WnK-TF-euS-view-b8z-vy-rbq.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/WnK-TF-euS-view-b8z-vy-rbq.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/dl0-K5-Mv3-view-OZg-SV-V5r.nib/objects-11.0+.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/dl0-K5-Mv3-view-OZg-SV-V5r.nib/objects-11.0+.nib index bec342e..8eb0145 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/dl0-K5-Mv3-view-OZg-SV-V5r.nib/objects-11.0+.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/dl0-K5-Mv3-view-OZg-SV-V5r.nib/objects-11.0+.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/dl0-K5-Mv3-view-OZg-SV-V5r.nib/runtime.nib b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/dl0-K5-Mv3-view-OZg-SV-V5r.nib/runtime.nib index e559268..3040de4 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/dl0-K5-Mv3-view-OZg-SV-V5r.nib/runtime.nib and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Apptentive.storyboardc/dl0-K5-Mv3-view-OZg-SV-V5r.nib/runtime.nib differ diff --git a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Info.plist b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Info.plist index 13b54fb..da17d23 100644 Binary files a/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Info.plist and b/src/ios/apptentive_ios_sdk/ApptentiveResources.bundle/Info.plist differ diff --git a/src/ios/apptentive_ios_sdk/include/Apptentive.h b/src/ios/apptentive_ios_sdk/include/Apptentive.h index ab5eaed..5cb9c0a 100644 --- a/src/ios/apptentive_ios_sdk/include/Apptentive.h +++ b/src/ios/apptentive_ios_sdk/include/Apptentive.h @@ -20,7 +20,7 @@ FOUNDATION_EXPORT double ApptentiveVersionNumber; FOUNDATION_EXPORT const unsigned char ApptentiveVersionString[]; /** The version number of the Apptentive SDK. */ -#define kApptentiveVersionString @"4.1.2" +#define kApptentiveVersionString @"5.0.0" /** The version number of the Apptentive API platform. */ #define kApptentiveAPIVersionString @"9" @@ -201,7 +201,7 @@ typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) { with a value of the id of the survey that was sent. */ -@interface Apptentive : NSObject +@interface Apptentive : NSObject ///--------------------------------- /// @name Basic Usage @@ -248,10 +248,20 @@ typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) { @param event A string representing the name of the event. @param viewController A view controller Apptentive UI may be presented from. If `nil`, a view controller should be provided by the delegate. + */ +- (void)engage:(NSString *)event fromViewController:(UIViewController *_Nullable)viewController NS_SWIFT_NAME(engage(event:from:)); - @return `YES` if an interaction was triggered by the event, `NO` otherwise. +/** + Shows interaction UI, if applicable, related to a given event. + + For example, if you have an upgrade message to display on app launch, you might call with event label set to + `@"app.launch"` here, along with the view controller an upgrade message might be displayed from. + + @param event A string representing the name of the event. + @param viewController A view controller Apptentive UI may be presented from. If `nil`, a view controller should be provided by the delegate. + @param completion A completion callback */ -- (BOOL)engage:(NSString *)event fromViewController:(UIViewController *_Nullable)viewController NS_SWIFT_NAME(engage(event:from:)); +- (void)engage:(NSString *)event fromViewController:(UIViewController *_Nullable)viewController completion:(void (^_Nullable)(BOOL engaged))completion NS_SWIFT_NAME(engage(event:from:completion:)); /** Shows interaction UI, if applicable, related to a given event, and attaches the specified custom data to the event. @@ -259,10 +269,18 @@ typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) { @param event A string representing the name of the event. @param customData A dictionary of key/value pairs to be associated with the event. Keys and values should conform to standards of NSJSONSerialization's `isValidJSONObject:`. @param viewController A view controller Apptentive UI may be presented from. If `nil`, a view controller should be provided by the delegate. + */ +- (void)engage:(NSString *)event withCustomData:(nullable NSDictionary *)customData fromViewController:(UIViewController *_Nullable)viewController NS_SWIFT_NAME(engage(event:withCustomData:from:)); - @return `YES` if an interaction was triggered by the event, `NO` otherwise. +/** + Shows interaction UI, if applicable, related to a given event, and attaches the specified custom data to the event. + + @param event A string representing the name of the event. + @param customData A dictionary of key/value pairs to be associated with the event. Keys and values should conform to standards of NSJSONSerialization's `isValidJSONObject:`. + @param viewController A view controller Apptentive UI may be presented from. If `nil`, a view controller should be provided by the delegate. + @param completion A completion callback */ -- (BOOL)engage:(NSString *)event withCustomData:(nullable NSDictionary *)customData fromViewController:(UIViewController *_Nullable)viewController NS_SWIFT_NAME(engage(event:withCustomData:from:)); +- (void)engage:(NSString *)event withCustomData:(nullable NSDictionary *)customData fromViewController:(UIViewController *_Nullable)viewController completion:(void (^_Nullable)(BOOL engaged))completion NS_SWIFT_NAME(engage(event:withCustomData:from:completion:)); /** Shows interaction UI, if applicable, related to a given event. Attaches the specified custom data to the event along with the specified extended data. @@ -271,21 +289,28 @@ typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) { @param customData A dictionary of key/value pairs to be associated with the event. Keys and values should conform to standards of NSJSONSerialization's `isValidJSONObject:`. @param extendedData An array of dictionaries with specific Apptentive formatting. For example, [Apptentive extendedDataDate:[NSDate date]]. @param viewController A view controller Apptentive UI may be presented from. If `nil`, a view controller should be provided by the delegate. + */ +- (void)engage:(NSString *)event withCustomData:(nullable NSDictionary *)customData withExtendedData:(nullable NSArray *)extendedData fromViewController:(UIViewController *_Nullable)viewController NS_SWIFT_NAME(engage(event:withCustomData:withExtendedData:from:)); - @return `YES` if an interaction was triggered by the event, `NO` otherwise. +/** + Shows interaction UI, if applicable, related to a given event. Attaches the specified custom data to the event along with the specified extended data. + + @param event A string representing the name of the event. + @param customData A dictionary of key/value pairs to be associated with the event. Keys and values should conform to standards of NSJSONSerialization's `isValidJSONObject:`. + @param extendedData An array of dictionaries with specific Apptentive formatting. For example, [Apptentive extendedDataDate:[NSDate date]]. + @param viewController A view controller Apptentive UI may be presented from. If `nil`, a view controller should be provided by the delegate. */ -- (BOOL)engage:(NSString *)event withCustomData:(nullable NSDictionary *)customData withExtendedData:(nullable NSArray *)extendedData fromViewController:(UIViewController *_Nullable)viewController NS_SWIFT_NAME(engage(event:withCustomData:withExtendedData:from:)); +- (void)engage:(NSString *)event withCustomData:(nullable NSDictionary *)customData withExtendedData:(nullable NSArray *)extendedData fromViewController:(UIViewController *_Nullable)viewController completion:(void (^_Nullable)(BOOL engaged))completion NS_SWIFT_NAME(engage(event:withCustomData:withExtendedData:from:completion:)); /** - Returns a Boolean value indicating whether the given event will cause an Interaction to be shown. + Asynchronously checks whether the given event will cause an Interaction to be shown. - For example, returns YES if a survey is ready to be shown the next time you engage your survey-targeted event. You can use this method to hide a "Show Survey" button in your app if there is no survey to take. + For example, callback would be invoked with YES parameter if a survey is ready to be shown the next time you engage your survey-targeted event. You can use this method to hide a "Show Survey" button in your app if there is no survey to take. @param event A string representing the name of the event. - - @return `YES` if the event will show an interaction, `NO` otherwise. + @param completion Completion callback */ -- (BOOL)canShowInteractionForEvent:(NSString *)event; +- (void)queryCanShowInteractionForEvent:(NSString *)event completion:(void (^)(BOOL canShowInteraction))completion; ///-------------------- /// @name Extended Data for Events @@ -357,14 +382,14 @@ typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) { ///-------------------- /** - Determines if Message Center will be displayed when `presentMessageCenterFromViewController:` is called. + Asynchronously determines if Message Center will be displayed when `presentMessageCenterFromViewController:` is called. - If app has not yet synced with Apptentive, you will be unable to display Message Center. Use `canShowMessageCenter` + If app has not yet synced with Apptentive, you will be unable to display Message Center. Use `queryCanShowMessageCenterWithCompletion:` to determine if Message Center is ready to be displayed. If Message Center is not ready you could, for example, hide the "Message Center" button in your interface. **/ -@property (readonly, nonatomic) BOOL canShowMessageCenter; +- (void)queryCanShowMessageCenterWithCompletion:(void (^)(BOOL canShowMessageCenter))completion; /** Presents Message Center modally from the specified view controller. @@ -373,10 +398,19 @@ typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) { "We're attempting to connect" view in place of Message Center. @param viewController The view controller from which to present Message Center. + */ +- (void)presentMessageCenterFromViewController:(nullable UIViewController *)viewController; - @return `YES` if Message Center was presented, `NO` otherwise. +/** + Presents Message Center modally from the specified view controller. + + If the SDK has yet to sync with the Apptentive server, this method returns NO and displays a + "We're attempting to connect" view in place of Message Center. + + @param viewController The view controller from which to present Message Center. + @param completion Completion callback. */ -- (BOOL)presentMessageCenterFromViewController:(nullable UIViewController *)viewController; +- (void)presentMessageCenterFromViewController:(nullable UIViewController *)viewController completion:(void (^_Nullable)(BOOL presented))completion; /** Presents Message Center from a given view controller with custom data. @@ -386,10 +420,20 @@ typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) { @param viewController The view controller from which to present Message Center. @param customData A dictionary of key/value pairs to be associated with any messages sent via Message Center. + */ +- (void)presentMessageCenterFromViewController:(nullable UIViewController *)viewController withCustomData:(nullable NSDictionary *)customData; - @return `YES` if Message Center was presented, `NO` otherwise. +/** + Presents Message Center from a given view controller with custom data. + + If the SDK has yet to sync with the Apptentive server, this method returns NO and displays a + "We're attempting to connect" view in place of Message Center. + + @param viewController The view controller from which to present Message Center. + @param customData A dictionary of key/value pairs to be associated with any messages sent via Message Center. + @param completion Completion callback. */ -- (BOOL)presentMessageCenterFromViewController:(nullable UIViewController *)viewController withCustomData:(nullable NSDictionary *)customData; +- (void)presentMessageCenterFromViewController:(nullable UIViewController *)viewController withCustomData:(nullable NSDictionary *)customData completion:(void (^_Nullable)(BOOL presented))completion; /** Dismisses Message Center. @@ -460,41 +504,49 @@ typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) { - (void)setPushNotificationIntegration:(ApptentivePushProvider)pushProvider withDeviceToken:(NSData *)deviceToken NS_SWIFT_NAME(setPushProvider(_:deviceToken:)); /** - Forwards a push notification from your application delegate to Apptentive Connect. + Forwards a push notification from your application delegate to Apptentive. + + Apptentive will attempt to fetch Messages Center messages in the background when the notification is received. - If the push notification originated from Apptentive, Message Center will be presented from the view controller - when the notification is tapped. + To enable background fetching of Message Center messages upon receiving a remote notification, + add `remote-notification` as a `UIBackgroundModes` value in your app's Info.plist. + + The `completionHandler` block will be called when the message fetch is completed. To ensure that messages can be + retrieved, please do not call the `completionHandler` block yourself if the notification was sent by Apptentive. + + If the notification was not sent by Apptentive, the parent app is responsible for calling the `completionHandler` block. @param userInfo The `userInfo` dictionary of the notification. - @param viewController The view controller Message Center may be presented from. + @param completionHandler The block to execute when the message fetch operation is complete. @return `YES` if the notification was sent by Apptentive, `NO` otherwise. */ -- (BOOL)didReceiveRemoteNotification:(NSDictionary *)userInfo fromViewController:(UIViewController *)viewController; +- (BOOL)didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler; /** Forwards a push notification from your application delegate to Apptentive. - If the push notification originated from Apptentive, Message Center will be presented from the view controller - when the notification is tapped. + Deprecated. The value passed to `fromViewController` is ignored. Use `-didReceveRemoteNotification:fetchCompletionHandler` instead. - Apptentive will attempt to fetch Messages Center messages in the background when the notification is received. + @param userInfo The `userInfo` dictionary of the notification. + @param viewController The view controller Message Center may be presented from. + @param completionHandler The block to execute when the message fetch operation is complete. - To enable background fetching of Message Center messages upon receiving a remote notification, - add `remote-notification` as a `UIBackgroundModes` value in your app's Info.plist. + @return `YES` if the notification was sent by Apptentive, `NO` otherwise. + */ +- (BOOL)didReceiveRemoteNotification:(NSDictionary *)userInfo fromViewController:(UIViewController *)viewController fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler DEPRECATED_ATTRIBUTE; - The `completionHandler` block will be called when the message fetch is completed. To ensure that messages can be - retrieved, please do not call the `completionHandler` block yourself if the notification was sent by Apptentive. +/** + Forwards a push notification from your application delegate to Apptentive Connect. - If the notification was not sent by Apptentive, the parent app is responsible for calling the `completionHandler` block. + Deprecated. The value passed to `fromViewController` is ignored. Use `-didReceiveRemoteNotification:fetchCompletionHandler:` instead. @param userInfo The `userInfo` dictionary of the notification. @param viewController The view controller Message Center may be presented from. - @param completionHandler The block to execute when the message fetch operation is complete. @return `YES` if the notification was sent by Apptentive, `NO` otherwise. */ -- (BOOL)didReceiveRemoteNotification:(NSDictionary *)userInfo fromViewController:(UIViewController *)viewController fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler; +- (BOOL)didReceiveRemoteNotification:(NSDictionary *)userInfo fromViewController:(UIViewController *)viewController DEPRECATED_ATTRIBUTE; /** Forwards a local notification from your application delegate to Apptentive. @@ -503,7 +555,6 @@ typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) { @param viewController The view controller Message Center may be presented from. @return `YES` if the notification was sent by Apptentive, `NO` otherwise. */ - #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - (BOOL)didReceiveLocalNotification:(UILocalNotification *)notification fromViewController:(UIViewController *)viewController NS_SWIFT_NAME(didReceiveLocalNotification(_:from:)); @@ -514,12 +565,33 @@ typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) { In the event that this method returns `NO`, your code must call the completion handler. @param response The notification response - @param completionHandler The completion handler that will be called if the notification was sent by Apptentive + @param viewController The view controller to present Message Center from. If absent, Message Center will be presented in a new window. + @param completionHandler The completion handler that will be called if the notification was sent by Apptentive. @return `YES` if the notification was sent by Apptentive, `NO` otherwise. */ +- (BOOL)didReceveUserNotificationResponse:(UNNotificationResponse *)response fromViewController:(nullable UIViewController *)viewController withCompletionHandler:(void (^)(void))completionHandler NS_AVAILABLE_IOS(10_0); -- (BOOL)didReceveUserNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler NS_AVAILABLE_IOS(10_0); +/** + Forwards a user notification from your user notification center delegate to Apptentive. + In the event that this method returns `NO`, your code must call the completion handler. + + @param response The notification response + @param completionHandler The completion handler that will be called if the notification was sent by Apptentive + @return `YES` if the notification was sent by Apptentive, `NO` otherwise. + +*/ +- (BOOL)didReceveUserNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler NS_AVAILABLE_IOS(10_0); + +/** + Tells the system to display an alert, if appropriate, for a notification. + In the event that this method returns `NO`, your code must call the completion handler. + + @param notification The notification + @param completionHandler The completion handler that will be called if the notification was sent by Apptentive + @return `YES` if the notification was sent by Apptentive, `NO` otherwise. + */ +- (BOOL)willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler; ///------------------------------------- /// @name Attach Text, Images, and Files @@ -720,7 +792,7 @@ typedef NS_ENUM(NSUInteger, ApptentiveLogLevel) { Deprecation Note: when a suitable view controller is not available for presenting interactions, the system will now use a new window to present Apptentive UI. */ -- (UIViewController *)viewControllerForInteractionsWithConnection:(Apptentive *)connection NS_SWIFT_NAME(viewControllerForInteractions(with:)) DEPRECATED_ATTRIBUTE; +- (UIViewController *)viewControllerForInteractionsWithConnection:(Apptentive *)connection NS_SWIFT_NAME(viewControllerForInteractions(with:))DEPRECATED_ATTRIBUTE; @end diff --git a/src/ios/apptentive_ios_sdk/include/ApptentiveStyleSheet.h b/src/ios/apptentive_ios_sdk/include/ApptentiveStyleSheet.h index 078d556..b786f98 100644 --- a/src/ios/apptentive_ios_sdk/include/ApptentiveStyleSheet.h +++ b/src/ios/apptentive_ios_sdk/include/ApptentiveStyleSheet.h @@ -6,8 +6,8 @@ // Copyright © 2016 Apptentive, Inc. All rights reserved. // -#import #import "Apptentive.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/src/ios/apptentive_ios_sdk/libapptentive-ios.a b/src/ios/apptentive_ios_sdk/libapptentive-ios.a index d8fe594..ee85cd8 100644 Binary files a/src/ios/apptentive_ios_sdk/libapptentive-ios.a and b/src/ios/apptentive_ios_sdk/libapptentive-ios.a differ