Skip to content

Commit 82bbb1f

Browse files
author
menelike
committed
be able to distinguish tapped messages in iOS (added tapped (boolean) property to additionalData)
1 parent 7f19752 commit 82bbb1f

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/ios/AppDelegate+notification.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N
121121

122122
pushHandler.notificationMessage = userInfo;
123123
pushHandler.isInline = NO;
124+
pushHandler.tapped = false;
124125
[pushHandler notificationReceived];
125126
} else {
126127
NSLog(@"just put it in the shade");
@@ -176,6 +177,7 @@ - (void)pushPluginOnApplicationDidBecomeActive:(NSNotification *)notification {
176177

177178
if (self.launchNotification) {
178179
pushHandler.isInline = NO;
180+
pushHandler.tapped = true;
179181
pushHandler.coldstart = [self.coldstart boolValue];
180182
pushHandler.notificationMessage = self.launchNotification;
181183
self.launchNotification = nil;
@@ -195,6 +197,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
195197
PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"];
196198
pushHandler.notificationMessage = notification.request.content.userInfo;
197199
pushHandler.isInline = YES;
200+
pushHandler.tapped = false;
198201
[pushHandler notificationReceived];
199202

200203
completionHandler(UNNotificationPresentationOptionNone);

src/ios/PushPlugin.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
{
3636
NSDictionary *notificationMessage;
3737
BOOL isInline;
38+
BOOL tapped;
3839
NSString *notificationCallbackId;
3940
NSString *callback;
4041
BOOL clearBadge;
@@ -51,6 +52,7 @@
5152

5253
@property (nonatomic, strong) NSDictionary *notificationMessage;
5354
@property BOOL isInline;
55+
@property BOOL tapped;
5456
@property BOOL coldstart;
5557
@property BOOL clearBadge;
5658
@property (nonatomic, strong) NSMutableDictionary *handlerObj;

src/ios/PushPlugin.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ @implementation PushPlugin : CDVPlugin
3636

3737
@synthesize notificationMessage;
3838
@synthesize isInline;
39+
@synthesize tapped;
3940
@synthesize coldstart;
4041

4142
@synthesize callbackId;
@@ -454,6 +455,12 @@ - (void)notificationReceived {
454455
[additionalData setObject:[NSNumber numberWithBool:NO] forKey:@"coldstart"];
455456
}
456457

458+
if (tapped) {
459+
[additionalData setObject:[NSNumber numberWithBool:YES] forKey:@"tapped"];
460+
} else {
461+
[additionalData setObject:[NSNumber numberWithBool:NO] forKey:@"tapped"];
462+
}
463+
457464
[message setObject:additionalData forKey:@"additionalData"];
458465

459466
// send notification message
@@ -463,6 +470,7 @@ - (void)notificationReceived {
463470

464471
self.coldstart = NO;
465472
self.notificationMessage = nil;
473+
self.tapped = false;
466474
}
467475
}
468476

0 commit comments

Comments
 (0)