Skip to content

Commit

Permalink
be able to distinguish tapped messages in iOS (added tapped (boolean)…
Browse files Browse the repository at this point in the history
… property to additionalData)
  • Loading branch information
menelike committed May 23, 2019
1 parent 7f19752 commit 82bbb1f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ios/AppDelegate+notification.m
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/ios/PushPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
{
NSDictionary *notificationMessage;
BOOL isInline;
BOOL tapped;
NSString *notificationCallbackId;
NSString *callback;
BOOL clearBadge;
Expand All @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/ios/PushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ @implementation PushPlugin : CDVPlugin

@synthesize notificationMessage;
@synthesize isInline;
@synthesize tapped;
@synthesize coldstart;

@synthesize callbackId;
Expand Down Expand Up @@ -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
Expand All @@ -463,6 +470,7 @@ - (void)notificationReceived {

self.coldstart = NO;
self.notificationMessage = nil;
self.tapped = false;
}
}

Expand Down

0 comments on commit 82bbb1f

Please sign in to comment.