|
|
@@ -32,6 +32,7 @@
|
|
|
@property (strong, nonatomic) UIApplication* app;
|
|
|
@property (strong, nonatomic) UNUserNotificationCenter* center;
|
|
|
@property (readwrite, assign) BOOL deviceready;
|
|
|
+@property (readonly, nonatomic, retain) NSArray* launchDetails;
|
|
|
@property (readonly, nonatomic, retain) NSMutableArray* eventQueue;
|
|
|
|
|
|
@end
|
|
|
@@ -43,6 +44,27 @@
|
|
|
#pragma mark -
|
|
|
#pragma mark Interface
|
|
|
|
|
|
+/**
|
|
|
+ * Set launchDetails object.
|
|
|
+ *
|
|
|
+ * @return [ Void ]
|
|
|
+ */
|
|
|
+- (void) launchDetails:(CDVInvokedUrlCommand*)command
|
|
|
+{
|
|
|
+ if (!_launchDetails)
|
|
|
+ return;
|
|
|
+
|
|
|
+ NSString* js;
|
|
|
+
|
|
|
+ js = [NSString stringWithFormat:
|
|
|
+ @"cordova.plugins.notification.local.launchDetails = {id:%@, action:'%@'}",
|
|
|
+ _launchDetails[0], _launchDetails[1]];
|
|
|
+
|
|
|
+ [self.commandDelegate evalJs:js];
|
|
|
+
|
|
|
+ _launchDetails = NULL;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Execute all queued events.
|
|
|
*
|
|
|
@@ -512,10 +534,10 @@
|
|
|
[self.commandDelegate runInBackground:^{
|
|
|
NSDictionary* options = command.arguments[0];
|
|
|
APPNotificationContent* notification;
|
|
|
-
|
|
|
+
|
|
|
notification = [[APPNotificationContent alloc]
|
|
|
initWithOptions:options];
|
|
|
-
|
|
|
+
|
|
|
[_center addNotificationCategory:notification.category];
|
|
|
[self execCallback:command];
|
|
|
}];
|
|
|
@@ -533,7 +555,7 @@
|
|
|
UNNotificationRequest* request = notification.request;
|
|
|
|
|
|
[_center addNotificationCategory:notification.category];
|
|
|
-
|
|
|
+
|
|
|
[_center addNotificationRequest:request withCompletionHandler:^(NSError* e) {
|
|
|
__strong APPLocalNotification* strongSelf = weakSelf;
|
|
|
[strongSelf fireEvent:@"add" notification:request];
|
|
|
@@ -582,7 +604,7 @@
|
|
|
UNNotificationRequest* notification = response.notification.request;
|
|
|
NSString* action = response.actionIdentifier;
|
|
|
NSString* event = action;
|
|
|
-
|
|
|
+
|
|
|
completionHandler();
|
|
|
|
|
|
if ([action isEqualToString:UNNotificationDefaultActionIdentifier]) {
|
|
|
@@ -591,11 +613,15 @@
|
|
|
if ([action isEqualToString:UNNotificationDismissActionIdentifier]) {
|
|
|
event = @"clear";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ if (!deviceready && [event isEqualToString:@"click"]) {
|
|
|
+ _launchDetails = @[notification.options.id, event];
|
|
|
+ }
|
|
|
+
|
|
|
if (![event isEqualToString:@"clear"]) {
|
|
|
[self fireEvent:@"clear" notification:notification];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
[self fireEvent:event notification:notification];
|
|
|
}
|
|
|
|
|
|
@@ -667,12 +693,12 @@
|
|
|
- (void) fireEvent:(NSString*)event
|
|
|
notification:(UNNotificationRequest*)request
|
|
|
{
|
|
|
- NSString* js;
|
|
|
- NSString* appState = [self applicationState];
|
|
|
- NSString* params = [NSString stringWithFormat:@"\"%@\"", appState];
|
|
|
+ NSString *js, *args;
|
|
|
+ NSString *appState = [self applicationState];
|
|
|
+ NSString *params = [NSString stringWithFormat:@"\"%@\"", appState];
|
|
|
|
|
|
if (request) {
|
|
|
- NSString* args = [request encodeToJSON];
|
|
|
+ args = [request encodeToJSON];
|
|
|
params = [NSString stringWithFormat:@"%@,'%@'", args, appState];
|
|
|
}
|
|
|
|