diff options
-rw-r--r-- | Juick/AppDelegate.h | 2 | ||||
-rw-r--r-- | Juick/AppDelegate.m | 11 | ||||
-rw-r--r-- | Juick/Supporting Files/Juick-Info.plist | 2 | ||||
-rw-r--r-- | Juick/ViewControllers/DiscoverViewController.m | 20 |
4 files changed, 31 insertions, 4 deletions
diff --git a/Juick/AppDelegate.h b/Juick/AppDelegate.h index 092fa20..4454022 100644 --- a/Juick/AppDelegate.h +++ b/Juick/AppDelegate.h @@ -14,4 +14,6 @@ -(void) registerForRemoteNotifications; +@property (strong, nonatomic) NSNumber *pushedThread; + @end diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m index 049e42e..4a8d762 100644 --- a/Juick/AppDelegate.m +++ b/Juick/AppDelegate.m @@ -28,7 +28,16 @@ [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; - [self registerForRemoteNotifications]; + [self registerForRemoteNotifications]; + NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]; + if (userInfo != nil) { + NSString *payload = [userInfo objectForKey:@"mid"]; + if (payload != nil) { + NSNumberFormatter *f = [NSNumberFormatter new]; + f.numberStyle = NSNumberFormatterOrdinalStyle; + self.pushedThread = [f numberFromString:payload]; + } + } return YES; } diff --git a/Juick/Supporting Files/Juick-Info.plist b/Juick/Supporting Files/Juick-Info.plist index c6816d5..535fda2 100644 --- a/Juick/Supporting Files/Juick-Info.plist +++ b/Juick/Supporting Files/Juick-Info.plist @@ -21,7 +21,7 @@ <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> - <string>1.0.22</string> + <string>1.0.23</string> <key>ITSAppUsesNonExemptEncryption</key> <false/> <key>LSApplicationCategoryType</key> diff --git a/Juick/ViewControllers/DiscoverViewController.m b/Juick/ViewControllers/DiscoverViewController.m index 4b22979..3c473d5 100644 --- a/Juick/ViewControllers/DiscoverViewController.m +++ b/Juick/ViewControllers/DiscoverViewController.m @@ -10,6 +10,7 @@ #import "ThreadViewController.h" #import "MessageCell.h" #import "APIClient.h" +#import "AppDelegate.h" @interface DiscoverViewController () @@ -17,6 +18,15 @@ @implementation DiscoverViewController +AppDelegate *appDelegate; + +-(void) awakeFromNib { + [super awakeFromNib]; + appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; + if (appDelegate.pushedThread != nil) { + [self performSegueWithIdentifier:@"threadViewSegue" sender:self]; + } +} -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { @@ -27,10 +37,16 @@ -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqual: @"threadViewSegue"]) { - Message *msg = [self.messages objectAtIndex:[self.tableView indexPathForSelectedRow].row]; + NSNumber *mid; + if (appDelegate.pushedThread != nil) { + mid = appDelegate.pushedThread; + } else { + Message *msg = [self.messages objectAtIndex:[self.tableView indexPathForSelectedRow].row]; + mid = msg.mid; + } ThreadViewController *threadVC = (ThreadViewController *)segue.destinationViewController; [threadVC setPath:[APIClient threadUrl]]; - [threadVC setParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:msg.mid, @"mid", nil]]; + [threadVC setParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:mid, @"mid", nil]]; } } |