2
0

Integrated Apptentive.

[ADDED]     Experimental support for Apptentive.
This commit is contained in:
Maarten Billemont
2012-05-23 08:58:01 +02:00
parent 2d8f2943e5
commit ac14b10752
7 changed files with 192 additions and 16 deletions

View File

@@ -15,6 +15,8 @@
#import "LocalyticsSession.h"
#import "TestFlight.h"
#import <Crashlytics/Crashlytics.h>
#import "ATConnect.h"
#import "ATAppRatingFlow.h"
@interface MPAppDelegate ()
@@ -24,6 +26,9 @@
- (NSString *)crashlyticsInfo;
- (NSString *)crashlyticsAPIKey;
- (NSString *)apptentiveInfo;
- (NSString *)apptentiveAPIKey;
- (NSString *)localyticsInfo;
- (NSString *)localyticsKey;
@@ -143,8 +148,8 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#ifndef DEBUG
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
#ifndef DEBUG
@try {
NSString *testFlightToken = [self testFlightToken];
if ([testFlightToken length]) {
@@ -200,9 +205,22 @@
@catch (NSException *exception) {
err(@"Localytics exception: %@", exception);
}
});
#endif
});
@try {
NSString *apptentiveAPIKey = [self apptentiveAPIKey];
if ([apptentiveAPIKey length]) {
dbg(@"Initializing Apptentive");
ATConnect *connection = [ATConnect sharedConnection];
connection.shouldTakeScreenshot = NO;
connection.apiKey = apptentiveAPIKey;
}
}
@catch (NSException *exception) {
err(@"Apptentive: %@", exception);
}
UIImage *navBarImage = [[UIImage imageNamed:@"ui_navbar_container"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsLandscapePhone];
@@ -270,11 +288,19 @@
@"https://youtrack.lyndir.com\n"
viewStyle:UIAlertViewStyleDefault tappedButtonBlock:nil
cancelTitle:nil otherTitles:[PearlStrings get].commonButtonOkay, nil];
#else
@try {
ATAppRatingFlow *sharedFlow = [ATAppRatingFlow sharedRatingFlowWithAppID:[PearlConfig get].iTunesID];
[sharedFlow appDidLaunch:YES viewController:self.navigationController];
}
@catch (NSException *exception) {
err(@"Apptentive: %@", exception);
}
#endif
[[UIApplication sharedApplication] setStatusBarHidden:NO
withAnimation:UIStatusBarAnimationSlide];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@@ -351,6 +377,11 @@
}
[TestFlight passCheckpoint:MPTestFlightCheckpointActivated];
ATAppRatingFlow *sharedFlow = [ATAppRatingFlow sharedRatingFlowWithAppID:[PearlConfig get].iTunesID];
[sharedFlow appDidEnterForeground:YES viewController:self.navigationController];
[super applicationDidBecomeActive:application];
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
@@ -502,6 +533,25 @@
}
#pragma mark - Apptentive
- (NSDictionary *)apptentiveInfo {
static NSDictionary *apptentiveInfo = nil;
if (apptentiveInfo == nil)
apptentiveInfo = [[NSDictionary alloc] initWithContentsOfURL:
[[NSBundle mainBundle] URLForResource:@"Apptentive" withExtension:@"plist"]];
return apptentiveInfo;
}
- (NSString *)apptentiveAPIKey {
return NullToNil([[self apptentiveInfo] valueForKeyPath:@"API Key"]);
}
#pragma mark - Localytics

View File

@@ -13,6 +13,7 @@
#import "MPElementGeneratedEntity.h"
#import "MPElementStoredEntity.h"
#import "IASKAppSettingsViewController.h"
#import "ATConnect.h"
#import <MobileCoreServices/MobileCoreServices.h>
@@ -393,36 +394,43 @@
return;
switch (buttonIndex - [sheet firstOtherButtonIndex]) {
case 0:
case 0: {
[self toggleHelpAnimated:YES];
break;
}
case 1: {
[self setHelpChapter:@"faq"];
[self setHelpHidden:NO animated:YES];
break;
}
case 2:
case 2: {
[[MPAppDelegate get] showGuide];
break;
case 3:
{
}
case 3: {
IASKAppSettingsViewController *settingsVC = [IASKAppSettingsViewController new];
settingsVC.delegate = self;
[self.navigationController pushViewController:settingsVC animated:YES];
break;
}
case 4:
case 4: {
[[MPAppDelegate get] export];
break;
}
#ifdef ADHOC
case 5:
case 5: {
[TestFlight openFeedbackView];
break;
case 6:
}
case 6: {
#else
case 5:
case 5: {
ATConnect *connection = [ATConnect sharedConnection];
[connection presentFeedbackControllerFromViewController:self];
break;
}
case 6: {
#endif
{
[[MPAppDelegate get] signOut:self];
[[MPAppDelegate get] loadKey:YES];
break;
@@ -433,9 +441,7 @@
} cancelTitle:[PearlStrings get].commonButtonCancel destructiveTitle:nil
otherTitles:
[self isHelpVisible]? @"Hide Help": @"Show Help", @"FAQ", @"Tutorial", @"Settings", @"Export",
#ifdef ADHOC
@"Feedback",
#endif
@"Sign Out",
nil];
}