1717
1818static NSString * const kAnalyticsTrackingID = @" UA-63011163-1" ;
1919
20- @interface AppDelegate () {
21- DataManager *_dataManager;
22- }
20+ @interface AppDelegate ()
2321
2422@end
2523
@@ -32,15 +30,14 @@ - (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 ] ;
33+ [UIApplication sharedApplication ]. applicationIconBadgeNumber = 0 ;
3634
3735 [ThemeManager setupTheme ];
3836
3937 [Fabric with: @[CrashlyticsKit]];
4038
4139 [self initializeAnalytics ];
4240 [self setupPushNotifications ];
43- [self clearAppBadge ];
4441
4542 self.window .rootViewController = [[UINavigationController alloc ] initWithRootViewController: [ComicListViewController new ]];
4643
@@ -73,21 +70,19 @@ - (void)application:(UIApplication *)application didRegisterUserNotificationSett
7370}
7471
7572- (void )application : (UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken : (NSData *)deviceToken {
76- NSString *token = [_dataManager tokenStringFromData: deviceToken];
73+ NSString *token = [[DataManager sharedInstance ] tokenStringFromData: deviceToken];
7774
7875 [[RequestManager sharedInstance ] sendDeviceToken: token completionHandler: ^(NSError *error) {
7976 if (error) {
8077 NSLog (@" Sending token to server failed with error: %@ " , error);
78+
79+ [[GTTracker sharedInstance ] sendAnalyticsEventWithCategory: @" Token Request Failed" action: error.localizedDescription];
8180 }
8281 }];
8382}
8483
8584- (void )application : (UIApplication *)application didReceiveRemoteNotification : (NSDictionary *)userInfo fetchCompletionHandler : (void (^)(UIBackgroundFetchResult))completionHandler {
86- [_dataManager performBackgroundFetchWithCompletionHandler: completionHandler];
87- }
88-
89- - (void )clearAppBadge {
90- [UIApplication sharedApplication ].applicationIconBadgeNumber = 0 ;
85+ [[DataManager sharedInstance ] performBackgroundFetchWithCompletionHandler: completionHandler];
9186}
9287
9388
0 commit comments