Skip to content

Added iOS8 notification actions #495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,36 @@ if ( device.platform == 'android' || device.platform == 'Android' || device.plat
pushTransportReadyCallback: replace_with_pushTransportReady_callback,
launchApplicationOnPush: true
});
} else if ( device.platform == 'iOS'){
pushNotification.register(
tokenHandler,
errorHandler,
{
"badge":"true",
"sound":"true",
"alert":"true",
"ecb":"onNotificationAPN",
"categories": [
{
"identifier": "new-message",
"actions": [
{
"title': 'View',
"identifier': "view",
"authentication": "false",
"mode": "foreground"
},
{
"title": "Delete",
"identifier": "delete",
"authentication': "false",
"destructive": "true",
"mode": "background"
}
]
}
]
});
} else {
pushNotification.register(
tokenHandler,
Expand Down Expand Up @@ -405,6 +435,18 @@ function onNotificationAPN (event) {
var snd = new Media(event.sound);
snd.play();
}

// iOS8 only
if ( event.category )
{
notification action category
}

// iOS8 only
if ( event.identifier )
{
notification action identifier
}

if ( event.badge )
{
Expand Down
21 changes: 21 additions & 0 deletions src/ios/AppDelegate+notification.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,25 @@ - (void)dealloc
self.launchNotification = nil; // clear the association and release the object
}


- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler
{
NSLog(@"didReceiveNotificationAction");

self.launchNotification = nil;

PushPlugin *pushHandler = [self getCommandInstance:@"PushPlugin"];
pushHandler.notificationMessage = userInfo;
pushHandler.identifier = identifier;
pushHandler.isInline = NO;
[pushHandler performSelectorOnMainThread:@selector(notificationReceived) withObject:pushHandler waitUntilDone:NO];

// need a way to cancel this to remove it from notification center
// [application cancelRemoteNotification:notification] ;

// Mandatory to call, as soon as you're done
completionHandler();
}


@end
2 changes: 2 additions & 0 deletions src/ios/PushPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
BOOL isInline;
NSString *notificationCallbackId;
NSString *callback;
NSString *identifier;

BOOL ready;
}
Expand All @@ -41,6 +42,7 @@
@property (nonatomic, copy) NSString *notificationCallbackId;
@property (nonatomic, copy) NSString *callback;

@property (nonatomic, strong) NSString *identifier;
@property (nonatomic, strong) NSDictionary *notificationMessage;
@property BOOL isInline;

Expand Down
Loading