Skip to content

Commit

Permalink
Refactored newsstand notification handling when app is already active
Browse files Browse the repository at this point in the history
  • Loading branch information
Xm4s committed Feb 19, 2013
1 parent 90e2728 commit 46bce6e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 27 deletions.
11 changes: 2 additions & 9 deletions Baker/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,8 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N
{
#ifdef BAKER_NEWSSTAND
NSDictionary *aps = [userInfo objectForKey:@"aps"];
if (aps) {
NSString *contentAvailable = [aps objectForKey:@"content-available"];
NSString *contentName = [aps objectForKey:@"content-name"];

if (contentAvailable && contentName && [contentAvailable caseInsensitiveCompare:@"1"] == NSOrderedSame) {
[[NSNotificationCenter defaultCenter] postNotificationName:[NSString stringWithFormat:@"notification_shelf_refresh_and_download"]
object:nil
userInfo:[NSDictionary dictionaryWithObject:contentName forKey:@"content-name"]];
}
if (aps && [aps objectForKey:@"content-available"]) {
[self applicationWillHandleNewsstandNotificationOfContent:[userInfo objectForKey:@"content-name"]];
}
#endif
}
Expand Down
1 change: 0 additions & 1 deletion BakerShelf/ShelfViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
#pragma mark - Shelf data source
- (NSUInteger)numberOfItemsInGridView:(AQGridView *)aGridView;
#ifdef BAKER_NEWSSTAND
- (void)didReceiveRefreshAndDownloadNotification:(NSNotification *)notification;
- (void)handleRefresh:(NSNotification *)notification;

#pragma mark - Store Kit
Expand Down
17 changes: 0 additions & 17 deletions BakerShelf/ShelfViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ - (id)init {
name:@"notification_restore_failed"];

[[SKPaymentQueue defaultQueue] addTransactionObserver:purchasesManager];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveRefreshAndDownloadNotification:)
name:@"notification_refresh_and_download"
object:nil];
#endif

issuesManager = [[IssuesManager sharedInstance] retain];
Expand Down Expand Up @@ -292,19 +288,6 @@ - (CGSize)portraitGridCellSizeForGridView:(AQGridView *)aGridView
}

#ifdef BAKER_NEWSSTAND
-(void)didReceiveRefreshAndDownloadNotification:(NSNotification *)notification {
[self handleRefresh:nil];

NSString *contentName = [notification.userInfo objectForKey:@"content-name"];
if (contentName) {
for (IssueViewController *controller in issueViewControllers) {
if ([controller.issue.ID isEqualToString:contentName]) {
[controller download];
break;
}
}
}
}
- (void)handleRefresh:(NSNotification *)notification {
[self setrefreshButtonEnabled:NO];

Expand Down

0 comments on commit 46bce6e

Please sign in to comment.