From 659c8741b35b9ed59c46de9af06064d7a645c602 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Tue, 5 Dec 2017 02:03:05 +0300
Subject: deep link
---
Juick/AppDelegate.h | 2 ++
Juick/AppDelegate.m | 11 ++++++++++-
Juick/Supporting Files/Juick-Info.plist | 2 +-
Juick/ViewControllers/DiscoverViewController.m | 20 ++++++++++++++++++--
4 files changed, 31 insertions(+), 4 deletions(-)
(limited to 'Juick')
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 @@
CFBundleSignature
????
CFBundleVersion
- 1.0.22
+ 1.0.23
ITSAppUsesNonExemptEncryption
LSApplicationCategoryType
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]];
}
}
--
cgit v1.2.3