summaryrefslogtreecommitdiff
path: root/Juick/AppDelegate.m
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-12-07 22:07:24 +0300
committerGravatar Vitaly Takmazov2017-12-07 22:07:24 +0300
commit229137d8c7f044dbda90e0d6fdf5f46666b0770d (patch)
tree88e91e6c27d06727cce0a41ebf9edd4fe3aa8746 /Juick/AppDelegate.m
parentd958ef04d427b284ccaa161a5634cd602802d415 (diff)
handle foreground push
Diffstat (limited to 'Juick/AppDelegate.m')
-rw-r--r--Juick/AppDelegate.m18
1 files changed, 14 insertions, 4 deletions
diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m
index 04a441c..26b10a8 100644
--- a/Juick/AppDelegate.m
+++ b/Juick/AppDelegate.m
@@ -17,6 +17,10 @@
#import "DeviceRegistration.h"
#import "NewPostViewController.h"
+@interface AppDelegate()
+-(void) parseNotificationPayload:(NSDictionary *)userInfo;
+@end
+
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
@@ -30,9 +34,7 @@
[self registerForRemoteNotifications];
NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
- if (userInfo != nil) {
- self.pushedThread = [userInfo objectForKey:@"mid"];
- }
+ [self parseNotificationPayload:userInfo];
return YES;
}
@@ -68,7 +70,9 @@
//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
- NSLog(@"User Info : %@",notification.request.content.userInfo);
+ NSDictionary *userInfo = notification.request.content.userInfo;
+ NSLog(@"User Info : %@", userInfo);
+ [self parseNotificationPayload:userInfo];
completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
}
@@ -78,4 +82,10 @@
completionHandler();
}
+-(void) parseNotificationPayload:(NSDictionary *)userInfo {
+ if (userInfo != nil) {
+ self.pushedThread = [userInfo objectForKey:@"mid"];
+ }
+}
+
@end