Skip to content

Commit 4805a09

Browse files
committed
Merge pull request #24 from mamaral/hotfix
Hotfix
2 parents 21c463b + 9a03d1c commit 4805a09

File tree

4 files changed

+19
-50
lines changed

4 files changed

+19
-50
lines changed

Source/App Delegate/AppDelegate.m

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
static NSString * const kAnalyticsTrackingID = @"UA-63011163-1";
1919

20-
@interface AppDelegate () {
21-
DataManager *_dataManager;
22-
}
20+
@interface AppDelegate ()
2321

2422
@end
2523

@@ -32,35 +30,24 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
3230
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
3331
self.window.backgroundColor = [UIColor whiteColor];
3432

35-
_dataManager = [DataManager sharedInstance];
36-
37-
[ThemeManager setupTheme];
38-
39-
[Fabric with:@[CrashlyticsKit]];
33+
application.applicationIconBadgeNumber = 0;
4034

41-
[self initializeAnalytics];
35+
[self setupThirdPartyLibraries];
4236
[self setupPushNotifications];
43-
[self clearAppBadge];
4437

4538
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[ComicListViewController new]];
46-
4739
[self.window makeKeyAndVisible];
4840

4941
return YES;
5042
}
5143

52-
- (void)applicationWillEnterForeground:(UIApplication *)application {
53-
[[GTTracker sharedInstance] startAnalyticsSession];
5444

55-
[self clearAppBadge];
56-
}
57-
58-
- (void)applicationDidEnterBackground:(UIApplication *)application {
59-
[[GTTracker sharedInstance] endAnalyticsSession];
60-
}
45+
#pragma mark - Third-party library setup
6146

62-
- (void)applicationWillTerminate:(UIApplication *)application {
63-
[[GTTracker sharedInstance] endAnalyticsSession];
47+
- (void)setupThirdPartyLibraries {
48+
[ThemeManager setupTheme];
49+
[Fabric with:@[CrashlyticsKit]];
50+
[[GTTracker sharedInstance] initializeAnalyticsWithTrackingID:kAnalyticsTrackingID logLevel:kGAILogLevelError];
6451
}
6552

6653

@@ -75,42 +62,19 @@ - (void)application:(UIApplication *)application didRegisterUserNotificationSett
7562
}
7663

7764
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
78-
NSString *token = [_dataManager tokenStringFromData:deviceToken];
65+
NSString *token = [[DataManager sharedInstance] tokenStringFromData:deviceToken];
7966

8067
[[RequestManager sharedInstance] sendDeviceToken:token completionHandler:^(NSError *error) {
8168
if (error) {
8269
NSLog(@"Sending token to server failed with error: %@", error);
70+
71+
[[GTTracker sharedInstance] sendAnalyticsEventWithCategory:@"Token Request Failed" action:error.localizedDescription];
8372
}
8473
}];
8574
}
8675

8776
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
88-
[_dataManager performBackgroundFetchWithCompletionHandler:completionHandler];
77+
[[DataManager sharedInstance] performBackgroundFetchWithCompletionHandler:completionHandler];
8978
}
9079

91-
- (void)clearAppBadge {
92-
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
93-
}
94-
95-
96-
#pragma mark - Analytics
97-
98-
- (void)initializeAnalytics {
99-
// Start up the GTTracker.
100-
GTTracker *tracker = [GTTracker sharedInstance];
101-
tracker.loggingEnabled = NO;
102-
[tracker initializeAnalyticsWithTrackingID:kAnalyticsTrackingID logLevel:kGAILogLevelError];
103-
}
104-
105-
106-
// TODO: Implement / test background fetch
107-
//
108-
//#pragma mark - Background fetch
109-
//
110-
//- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
111-
// // Let the data manger handle the fetch.
112-
// [[DataManager sharedInstance] performBackgroundFetchWithCompletionHandler:completionHandler];
113-
//}
114-
115-
11680
@end

Source/Managers/Data Manager/DataManager.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ - (void)performBackgroundFetchWithCompletionHandler:(void (^)(UIBackgroundFetchR
165165
else if (newData) {
166166
completionHandler(UIBackgroundFetchResultNewData);
167167

168-
[[NSNotificationCenter defaultCenter] postNotificationName:@"NEW_COMICS_AVAILABLE" object:nil];
168+
[[NSNotificationCenter defaultCenter] postNotificationName:NewComicsAvailableNotification object:nil];
169169
}
170170

171171
else {

Source/Misc/Supporting Files/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>7</string>
22+
<string>8</string>
2323
<key>Fabric</key>
2424
<dict>
2525
<key>APIKey</key>

Source/View Controllers/Comic List/ComicListViewController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ - (void)viewDidAppear:(BOOL)animated {
8181
[super viewDidAppear:animated];
8282

8383
[[GTTracker sharedInstance] sendScreenEventWithTitle:@"Comic List"];
84+
85+
// Clear the app badge here, as we can be reasonably sure at this point anything new
86+
// will have been seen, and we won't run into annoying issues related to the app
87+
// life-cycle that we've experienced before.
88+
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
8489
}
8590

8691
- (void)viewWillLayoutSubviews {

0 commit comments

Comments
 (0)