From 82bbb1f6a68d9d7f4618fbb8f442bddb02da8072 Mon Sep 17 00:00:00 2001 From: menelike Date: Thu, 23 May 2019 16:35:42 +0200 Subject: [PATCH] be able to distinguish tapped messages in iOS (added tapped (boolean) property to additionalData) --- src/ios/AppDelegate+notification.m | 3 +++ src/ios/PushPlugin.h | 2 ++ src/ios/PushPlugin.m | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/src/ios/AppDelegate+notification.m b/src/ios/AppDelegate+notification.m index b04c47687..6b75c3b7d 100644 --- a/src/ios/AppDelegate+notification.m +++ b/src/ios/AppDelegate+notification.m @@ -121,6 +121,7 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N pushHandler.notificationMessage = userInfo; pushHandler.isInline = NO; + pushHandler.tapped = false; [pushHandler notificationReceived]; } else { NSLog(@"just put it in the shade"); @@ -176,6 +177,7 @@ - (void)pushPluginOnApplicationDidBecomeActive:(NSNotification *)notification { if (self.launchNotification) { pushHandler.isInline = NO; + pushHandler.tapped = true; pushHandler.coldstart = [self.coldstart boolValue]; pushHandler.notificationMessage = self.launchNotification; self.launchNotification = nil; @@ -195,6 +197,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"]; pushHandler.notificationMessage = notification.request.content.userInfo; pushHandler.isInline = YES; + pushHandler.tapped = false; [pushHandler notificationReceived]; completionHandler(UNNotificationPresentationOptionNone); diff --git a/src/ios/PushPlugin.h b/src/ios/PushPlugin.h index 4b6ec930a..21009f709 100644 --- a/src/ios/PushPlugin.h +++ b/src/ios/PushPlugin.h @@ -35,6 +35,7 @@ { NSDictionary *notificationMessage; BOOL isInline; + BOOL tapped; NSString *notificationCallbackId; NSString *callback; BOOL clearBadge; @@ -51,6 +52,7 @@ @property (nonatomic, strong) NSDictionary *notificationMessage; @property BOOL isInline; +@property BOOL tapped; @property BOOL coldstart; @property BOOL clearBadge; @property (nonatomic, strong) NSMutableDictionary *handlerObj; diff --git a/src/ios/PushPlugin.m b/src/ios/PushPlugin.m index 0290c8ecc..17ffdc653 100644 --- a/src/ios/PushPlugin.m +++ b/src/ios/PushPlugin.m @@ -36,6 +36,7 @@ @implementation PushPlugin : CDVPlugin @synthesize notificationMessage; @synthesize isInline; +@synthesize tapped; @synthesize coldstart; @synthesize callbackId; @@ -454,6 +455,12 @@ - (void)notificationReceived { [additionalData setObject:[NSNumber numberWithBool:NO] forKey:@"coldstart"]; } + if (tapped) { + [additionalData setObject:[NSNumber numberWithBool:YES] forKey:@"tapped"]; + } else { + [additionalData setObject:[NSNumber numberWithBool:NO] forKey:@"tapped"]; + } + [message setObject:additionalData forKey:@"additionalData"]; // send notification message @@ -463,6 +470,7 @@ - (void)notificationReceived { self.coldstart = NO; self.notificationMessage = nil; + self.tapped = false; } }