Commit 9c65b6c2 by Sebastián Katzer

Update to latest dev

parent 6540f331
......@@ -18,12 +18,13 @@
D0D06B90644D41EAAE8C16D6 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4042BD923824AEB9E9079DC /* QuartzCore.framework */; };
E09211A0D1294D6588191EB4 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = B49413F707024AE39907B73F /* libz.tbd */; };
E27F123D4ACE4BF39165B055 /* CDVDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A150CBE2B3E47C5A4319096 /* CDVDevice.m */; };
594B396610F44146B9829378 /* APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 6ABEB0FF63984DDC87BAC009 /* APPLocalNotification.m */; };
F1270C8DA6B14E818449922C /* APPNotificationContent.m in Sources */ = {isa = PBXBuildFile; fileRef = A1C99F8EB00B48598DE0C517 /* APPNotificationContent.m */; };
060A1D75E57344CFBB3FF6EF /* APPNotificationOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = E5B9A01906E548B9BDB12D62 /* APPNotificationOptions.m */; };
626BE4156FA0453A94A8800E /* UNUserNotificationCenter+APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BEF939469F9450CA22340E9 /* UNUserNotificationCenter+APPLocalNotification.m */; };
0B2ED59A6D1C4E32A180CA06 /* UNNotificationRequest+APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 303143ED332846A2BFCCA3B3 /* UNNotificationRequest+APPLocalNotification.m */; };
3018B0877875443CBA388811 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C110E99320F24AFFB1B0DB35 /* UserNotifications.framework */; };
F8C0095E58304CDA88167C07 /* APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 883054076F4F42B2BFE374BB /* APPLocalNotification.m */; };
583F6EE2D5C44179A9EF077D /* APPNotificationContent.m in Sources */ = {isa = PBXBuildFile; fileRef = E5A6BF77F5ED486F9BFE3DEC /* APPNotificationContent.m */; };
DDE963D727044DE4925AA9E1 /* APPNotificationOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 09B14F03C5FD43248C58E15B /* APPNotificationOptions.m */; };
01A490EDB5BE40E4AEEC5E9C /* UNUserNotificationCenter+APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 8466AA945B6D4989A262FC18 /* UNUserNotificationCenter+APPLocalNotification.m */; };
CAF775B02AEE4B3DB3595BC0 /* UNNotificationRequest+APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 172633A5622E40109D708A09 /* UNNotificationRequest+APPLocalNotification.m */; };
21DEA5CE68BF4E039638C4AF /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6B59A7831EF4394828B3370 /* UserNotifications.framework */; };
6550B5FDD9914A9E99DCC1DC /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2E54A42FBB604A0EA11AAF6C /* CoreLocation.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
......@@ -79,17 +80,18 @@
EB87FDF41871DAF40020F90C /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = ../../config.xml; sourceTree = "<group>"; };
ED33DF2A687741AEAF9F8254 /* Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bridging-Header.h"; sourceTree = "<group>"; };
F840E1F0165FE0F500CFE078 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = NotificationExample/config.xml; sourceTree = "<group>"; };
6ABEB0FF63984DDC87BAC009 /* APPLocalNotification.m */ = {isa = PBXFileReference; name = "APPLocalNotification.m"; path = "cordova-plugin-local-notifications/APPLocalNotification.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
A1C99F8EB00B48598DE0C517 /* APPNotificationContent.m */ = {isa = PBXFileReference; name = "APPNotificationContent.m"; path = "cordova-plugin-local-notifications/APPNotificationContent.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
E5B9A01906E548B9BDB12D62 /* APPNotificationOptions.m */ = {isa = PBXFileReference; name = "APPNotificationOptions.m"; path = "cordova-plugin-local-notifications/APPNotificationOptions.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
6BEF939469F9450CA22340E9 /* UNUserNotificationCenter+APPLocalNotification.m */ = {isa = PBXFileReference; name = "UNUserNotificationCenter+APPLocalNotification.m"; path = "cordova-plugin-local-notifications/UNUserNotificationCenter+APPLocalNotification.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
303143ED332846A2BFCCA3B3 /* UNNotificationRequest+APPLocalNotification.m */ = {isa = PBXFileReference; name = "UNNotificationRequest+APPLocalNotification.m"; path = "cordova-plugin-local-notifications/UNNotificationRequest+APPLocalNotification.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
B2458798FCD44982BD691F09 /* APPLocalNotification.h */ = {isa = PBXFileReference; name = "APPLocalNotification.h"; path = "cordova-plugin-local-notifications/APPLocalNotification.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
5206BD199127420A9B0CDE6D /* APPNotificationContent.h */ = {isa = PBXFileReference; name = "APPNotificationContent.h"; path = "cordova-plugin-local-notifications/APPNotificationContent.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
4A51D2A1078F43C9921407ED /* APPNotificationOptions.h */ = {isa = PBXFileReference; name = "APPNotificationOptions.h"; path = "cordova-plugin-local-notifications/APPNotificationOptions.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
82A625C4BA544DD5B8A6AE28 /* UNUserNotificationCenter+APPLocalNotification.h */ = {isa = PBXFileReference; name = "UNUserNotificationCenter+APPLocalNotification.h"; path = "cordova-plugin-local-notifications/UNUserNotificationCenter+APPLocalNotification.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
4B309C7C65224315805573F7 /* UNNotificationRequest+APPLocalNotification.h */ = {isa = PBXFileReference; name = "UNNotificationRequest+APPLocalNotification.h"; path = "cordova-plugin-local-notifications/UNNotificationRequest+APPLocalNotification.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
C110E99320F24AFFB1B0DB35 /* UserNotifications.framework */ = {isa = PBXFileReference; name = "UserNotifications.framework"; path = "System/Library/Frameworks/UserNotifications.framework"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = wrapper.framework; explicitFileType = undefined; includeInIndex = 0; };
883054076F4F42B2BFE374BB /* APPLocalNotification.m */ = {isa = PBXFileReference; name = "APPLocalNotification.m"; path = "cordova-plugin-local-notifications/APPLocalNotification.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
E5A6BF77F5ED486F9BFE3DEC /* APPNotificationContent.m */ = {isa = PBXFileReference; name = "APPNotificationContent.m"; path = "cordova-plugin-local-notifications/APPNotificationContent.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
09B14F03C5FD43248C58E15B /* APPNotificationOptions.m */ = {isa = PBXFileReference; name = "APPNotificationOptions.m"; path = "cordova-plugin-local-notifications/APPNotificationOptions.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
8466AA945B6D4989A262FC18 /* UNUserNotificationCenter+APPLocalNotification.m */ = {isa = PBXFileReference; name = "UNUserNotificationCenter+APPLocalNotification.m"; path = "cordova-plugin-local-notifications/UNUserNotificationCenter+APPLocalNotification.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
172633A5622E40109D708A09 /* UNNotificationRequest+APPLocalNotification.m */ = {isa = PBXFileReference; name = "UNNotificationRequest+APPLocalNotification.m"; path = "cordova-plugin-local-notifications/UNNotificationRequest+APPLocalNotification.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
63873E734B3C460C93922F8B /* APPLocalNotification.h */ = {isa = PBXFileReference; name = "APPLocalNotification.h"; path = "cordova-plugin-local-notifications/APPLocalNotification.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
0F64FF1951E549C981D4C727 /* APPNotificationContent.h */ = {isa = PBXFileReference; name = "APPNotificationContent.h"; path = "cordova-plugin-local-notifications/APPNotificationContent.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
47D738D5436A46B6BD1DEC2C /* APPNotificationOptions.h */ = {isa = PBXFileReference; name = "APPNotificationOptions.h"; path = "cordova-plugin-local-notifications/APPNotificationOptions.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
CC1D7BFEF2AF4F85A2AA04ED /* UNUserNotificationCenter+APPLocalNotification.h */ = {isa = PBXFileReference; name = "UNUserNotificationCenter+APPLocalNotification.h"; path = "cordova-plugin-local-notifications/UNUserNotificationCenter+APPLocalNotification.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
8BF09BB30DEA49D6A1C4C902 /* UNNotificationRequest+APPLocalNotification.h */ = {isa = PBXFileReference; name = "UNNotificationRequest+APPLocalNotification.h"; path = "cordova-plugin-local-notifications/UNNotificationRequest+APPLocalNotification.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
F6B59A7831EF4394828B3370 /* UserNotifications.framework */ = {isa = PBXFileReference; name = "UserNotifications.framework"; path = "System/Library/Frameworks/UserNotifications.framework"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = wrapper.framework; explicitFileType = undefined; includeInIndex = 0; };
2E54A42FBB604A0EA11AAF6C /* CoreLocation.framework */ = {isa = PBXFileReference; name = "CoreLocation.framework"; path = "System/Library/Frameworks/CoreLocation.framework"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = wrapper.framework; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -100,7 +102,8 @@
301BF552109A68D80062928A /* libCordova.a in Frameworks */,
E09211A0D1294D6588191EB4 /* libz.tbd in Frameworks */,
D0D06B90644D41EAAE8C16D6 /* QuartzCore.framework in Frameworks */,
3018B0877875443CBA388811 /* UserNotifications.framework in Frameworks */,
21DEA5CE68BF4E039638C4AF /* UserNotifications.framework in Frameworks */,
6550B5FDD9914A9E99DCC1DC /* CoreLocation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -173,7 +176,8 @@
children = (
B49413F707024AE39907B73F /* libz.tbd */,
E4042BD923824AEB9E9079DC /* QuartzCore.framework */,
C110E99320F24AFFB1B0DB35 /* UserNotifications.framework */,
F6B59A7831EF4394828B3370 /* UserNotifications.framework */,
2E54A42FBB604A0EA11AAF6C /* CoreLocation.framework */,
);
name = Frameworks;
sourceTree = "<group>";
......@@ -206,16 +210,16 @@
816F86ACE6CD4C8E8FA7A84A /* Toast.m */,
A380129C71E248EDBC5BE744 /* Toast+UIView.h */,
84764C161F33453AB5FD1235 /* Toast.h */,
6ABEB0FF63984DDC87BAC009 /* APPLocalNotification.m */,
A1C99F8EB00B48598DE0C517 /* APPNotificationContent.m */,
E5B9A01906E548B9BDB12D62 /* APPNotificationOptions.m */,
6BEF939469F9450CA22340E9 /* UNUserNotificationCenter+APPLocalNotification.m */,
303143ED332846A2BFCCA3B3 /* UNNotificationRequest+APPLocalNotification.m */,
B2458798FCD44982BD691F09 /* APPLocalNotification.h */,
5206BD199127420A9B0CDE6D /* APPNotificationContent.h */,
4A51D2A1078F43C9921407ED /* APPNotificationOptions.h */,
82A625C4BA544DD5B8A6AE28 /* UNUserNotificationCenter+APPLocalNotification.h */,
4B309C7C65224315805573F7 /* UNNotificationRequest+APPLocalNotification.h */,
883054076F4F42B2BFE374BB /* APPLocalNotification.m */,
E5A6BF77F5ED486F9BFE3DEC /* APPNotificationContent.m */,
09B14F03C5FD43248C58E15B /* APPNotificationOptions.m */,
8466AA945B6D4989A262FC18 /* UNUserNotificationCenter+APPLocalNotification.m */,
172633A5622E40109D708A09 /* UNNotificationRequest+APPLocalNotification.m */,
63873E734B3C460C93922F8B /* APPLocalNotification.h */,
0F64FF1951E549C981D4C727 /* APPNotificationContent.h */,
47D738D5436A46B6BD1DEC2C /* APPNotificationOptions.h */,
CC1D7BFEF2AF4F85A2AA04ED /* UNUserNotificationCenter+APPLocalNotification.h */,
8BF09BB30DEA49D6A1C4C902 /* UNNotificationRequest+APPLocalNotification.h */,
);
name = Plugins;
path = NotificationExample/Plugins;
......@@ -346,11 +350,11 @@
E27F123D4ACE4BF39165B055 /* CDVDevice.m in Sources */,
CA605C2FE84D46FC94CE18B1 /* Toast+UIView.m in Sources */,
91E68846231A433A8F26E364 /* Toast.m in Sources */,
594B396610F44146B9829378 /* APPLocalNotification.m in Sources */,
F1270C8DA6B14E818449922C /* APPNotificationContent.m in Sources */,
060A1D75E57344CFBB3FF6EF /* APPNotificationOptions.m in Sources */,
626BE4156FA0453A94A8800E /* UNUserNotificationCenter+APPLocalNotification.m in Sources */,
0B2ED59A6D1C4E32A180CA06 /* UNNotificationRequest+APPLocalNotification.m in Sources */,
F8C0095E58304CDA88167C07 /* APPLocalNotification.m in Sources */,
583F6EE2D5C44179A9EF077D /* APPNotificationContent.m in Sources */,
DDE963D727044DE4925AA9E1 /* APPNotificationOptions.m in Sources */,
01A490EDB5BE40E4AEEC5E9C /* UNUserNotificationCenter+APPLocalNotification.m in Sources */,
CAF775B02AEE4B3DB3595BC0 /* UNNotificationRequest+APPLocalNotification.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
/*
* Copyright (c) 2013 by appPlant GmbH. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import <Cordova/CDVPlugin.h>
......@@ -27,6 +21,8 @@
@interface APPLocalNotification : CDVPlugin <UNUserNotificationCenterDelegate>
// Set launchDetails object
- (void) launchDetails:(CDVInvokedUrlCommand*)command;
// Execute all queued events
- (void) deviceready:(CDVInvokedUrlCommand*)command;
......
/*
* Copyright (c) 2013 by appPlant GmbH. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPLocalNotification.h"
......@@ -32,6 +26,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
......@@ -44,6 +39,27 @@
#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.
*
* @return [ Void ]
......@@ -512,10 +528,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 +549,7 @@
UNNotificationRequest* request = notification.request;
[_center addNotificationCategory:notification.category];
[_center addNotificationRequest:request withCompletionHandler:^(NSError* e) {
__strong APPLocalNotification* strongSelf = weakSelf;
[strongSelf fireEvent:@"add" notification:request];
......@@ -583,6 +599,8 @@
NSString* action = response.actionIdentifier;
NSString* event = action;
completionHandler();
if ([action isEqualToString:UNNotificationDefaultActionIdentifier]) {
event = @"click";
} else
......@@ -590,9 +608,15 @@
event = @"clear";
}
[self fireEvent:event notification:notification];
if (!deviceready && [event isEqualToString:@"click"]) {
_launchDetails = @[notification.options.id, event];
}
completionHandler();
if (![event isEqualToString:@"clear"]) {
[self fireEvent:@"clear" notification:notification];
}
[self fireEvent:event notification:notification];
}
#pragma mark -
......@@ -663,12 +687,12 @@
- (void) fireEvent:(NSString*)event
notification:(UNNotificationRequest*)request
{
NSString* js;
NSString* appState = [self applicationState];
NSString* params = [NSString stringWithFormat:@"\"%@\"", appState];
NSString *js;
NSString *appState = [self applicationState];
NSString *params = [NSString stringWithFormat:@"\"%@\"", appState];
if (request) {
NSString* args = [request encodeToJSON];
NSString *args = [request encodeToJSON];
params = [NSString stringWithFormat:@"%@,'%@'", args, appState];
}
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPNotificationOptions.h"
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPNotificationContent.h"
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
@import UserNotifications;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,13 +13,12 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPNotificationOptions.h"
#import "UNUserNotificationCenter+APPLocalNotification.h"
@import CoreLocation;
@import UserNotifications;
@interface APPNotificationOptions ()
......@@ -52,7 +47,7 @@
self = [self init];
self.dict = dictionary;
[self actions];
return self;
......@@ -62,6 +57,18 @@
#pragma mark Properties
/**
* The type for the notification.
*
* @return [ NSString* ]
*/
- (NSString*) type
{
NSString* type = [dict objectForKey:@"type"];
return type.length ? type : @"normal";
}
/**
* The ID for the notification.
*
* @return [ NSNumber* ]
......@@ -123,7 +130,7 @@
- (NSNumber*) badge
{
id value = [dict objectForKey:@"badge"];
return (value == NULL) ? NULL : [NSNumber numberWithInt:[value intValue]];
}
......@@ -135,7 +142,7 @@
- (NSString*) categoryId
{
NSString* value = [dict objectForKey:@"actionGroupId"];
return value.length ? value : kAPPGeneralCategory;
}
......@@ -175,10 +182,10 @@
{
NSArray* paths = [dict objectForKey:@"attachments"];
NSMutableArray* attachments = [[NSMutableArray alloc] init];
if (!paths)
return attachments;
for (NSString* path in paths) {
NSURL* url = [self urlForAttachmentPath:path];
......@@ -187,12 +194,12 @@
URL:url
options:NULL
error:NULL];
if (attachment) {
[attachments addObject:attachment];
}
}
return attachments;
}
......@@ -205,35 +212,57 @@
{
NSArray* items = [dict objectForKey:@"actions"];
NSMutableArray* actions = [[NSMutableArray alloc] init];
if (!items)
return actions;
for (NSDictionary* item in items) {
NSString* id = [item objectForKey:@"id"];
NSString* title = [item objectForKey:@"title"];
NSString* type = [item objectForKey:@"type"];
UNNotificationActionOptions options = UNNotificationActionOptionNone;
UNNotificationAction* action;
if ([[item objectForKey:@"launch"] boolValue]) {
options = UNNotificationActionOptionForeground;
}
if ([[item objectForKey:@"ui"] isEqualToString:@"decline"]) {
options = options | UNNotificationActionOptionDestructive;
}
if ([[item objectForKey:@"needsAuth"] boolValue]) {
options = options | UNNotificationActionOptionAuthenticationRequired;
}
UNNotificationAction* action;
action = [UNNotificationAction actionWithIdentifier:id
title:title
options:options];
[actions addObject:action];
if ([type isEqualToString:@"input"]) {
NSString* submitTitle = [item objectForKey:@"submitTitle"];
NSString* placeholder = [item objectForKey:@"emptyText"];
if (!submitTitle.length) {
submitTitle = @"Submit";
}
action = [UNTextInputNotificationAction actionWithIdentifier:id
title:title
options:options
textInputButtonTitle:submitTitle
textInputPlaceholder:placeholder];
} else
if (!type.length || [type isEqualToString:@"button"]) {
action = [UNNotificationAction actionWithIdentifier:id
title:title
options:options];
} else {
NSLog(@"Unknown action type: %@", type);
}
if (action) {
[actions addObject:action];
}
}
return actions;
}
......@@ -247,6 +276,14 @@
*/
- (UNNotificationTrigger*) trigger
{
NSString* type = [self type];
if ([type isEqualToString:@"location"])
return [self triggerWithRegion];
if (![type isEqualToString:@"normal"])
NSLog(@"Unknown type: %@", type);
if ([self isRepeating])
return [self repeatingTrigger];
......@@ -283,7 +320,7 @@
{
double timestamp = [[dict objectForKey:@"at"]
doubleValue];
return [NSDate dateWithTimeIntervalSince1970:timestamp];
}
......@@ -326,12 +363,12 @@
id every = [dict objectForKey:@"every"];
if ([every isKindOfClass:NSString.class])
return [self repeatingTriggerWithDateMatchingComponents];
return [self triggerWithDateMatchingComponents];
if ([every isKindOfClass:NSDictionary.class])
return [self repeatingTriggerWithCustomDateMatchingComponents];
return [self triggerWithCustomDateMatchingComponents];
return [self repeatingTriggerWithTimeInterval];
return [self triggerWithTimeInterval];
}
/**
......@@ -339,7 +376,7 @@
*
* @return [ UNTimeIntervalNotificationTrigger* ]
*/
- (UNTimeIntervalNotificationTrigger*) repeatingTriggerWithTimeInterval
- (UNTimeIntervalNotificationTrigger*) triggerWithTimeInterval
{
long interval = [[dict objectForKey:@"every"] longValue];
......@@ -357,7 +394,7 @@
*
* @return [ UNCalendarNotificationTrigger* ]
*/
- (UNCalendarNotificationTrigger*) repeatingTriggerWithDateMatchingComponents
- (UNCalendarNotificationTrigger*) triggerWithDateMatchingComponents
{
NSCalendar* cal = [[NSCalendar alloc]
initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
......@@ -376,7 +413,7 @@
*
* @return [ UNCalendarNotificationTrigger* ]
*/
- (UNCalendarNotificationTrigger*) repeatingTriggerWithCustomDateMatchingComponents
- (UNCalendarNotificationTrigger*) triggerWithCustomDateMatchingComponents
{
NSCalendar* cal = [[NSCalendar alloc]
initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
......@@ -391,6 +428,30 @@
}
/**
* A repeating trigger based on a location region.
*
* @return [ UNLocationNotificationTrigger* ]
*/
- (UNLocationNotificationTrigger*) triggerWithRegion
{
NSArray* center = [dict objectForKey:@"center"];
double radius = [[dict objectForKey:@"radius"] doubleValue];
CLLocationCoordinate2D coord =
CLLocationCoordinate2DMake([center[0] doubleValue], [center[1] doubleValue]);
CLCircularRegion* region =
[[CLCircularRegion alloc] initWithCenter:coord
radius:radius
identifier:self.identifier];
region.notifyOnEntry = [[dict objectForKey:@"notifyOnEntry"] boolValue];
region.notifyOnExit = [[dict objectForKey:@"notifyOnExit"] boolValue];
return [UNLocationNotificationTrigger triggerWithRegion:region repeats:YES];
}
/**
* The time interval between the next fire date and now.
*
* @return [ double ]
......@@ -580,7 +641,7 @@
if ([path isEqualToString:@"res://icon"]) {
path = @"res://AppIcon60x60@3x.png";
}
NSString* absPath;
absPath = [path stringByReplacingOccurrencesOfString:@"res:/"
withString:@""];
......@@ -606,7 +667,7 @@
NSFileManager* fm = [NSFileManager defaultManager];
NSBundle* mainBundle = [NSBundle mainBundle];
NSString* bundlePath = [mainBundle bundlePath];
NSString* absPath;
absPath = [path stringByReplacingOccurrencesOfString:@"file:/"
withString:@"/www"];
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPNotificationOptions.h"
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPNotificationOptions.h"
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPNotificationContent.h"
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "UNUserNotificationCenter+APPLocalNotification.h"
......@@ -62,17 +56,17 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
{
if (!category)
return;
[self getNotificationCategoriesWithCompletionHandler:^(NSSet<UNNotificationCategory *> *set) {
NSMutableSet* categories = [NSMutableSet setWithSet:set];
for (UNNotificationCategory* item in categories) {
if ([category.identifier isEqualToString:item.identifier]) {
[categories removeObject:item];
break;
}
}
[categories addObject:category];
[self setNotificationCategories:categories];
}];
......
{
"libz.tbd": 1,
"QuartzCore.framework": 1,
"UserNotifications.framework": 1
"UserNotifications.framework": 1,
"CoreLocation.framework": 1
}
\ No newline at end of file
......@@ -22,6 +22,7 @@ var exec = require('cordova/exec'),
// Default values
exports._defaults = {
id: 0,
type: 'normal',
text: '',
title: '',
sound: 'res://platform_default',
......@@ -55,6 +56,8 @@ exports.applyPlatformSpecificOptions = function () {
break;
case 'iOS':
defaults.attachments = undefined;
defaults.region = undefined;
defaults.radius = undefined;
break;
}
};
......@@ -303,11 +306,13 @@ exports.exec = function (action, args, callback, scope) {
channel.deviceready.subscribe(function () {
// Device is ready now, the listeners are registered
// and all queued events can be executed.
exec(null, null, 'LocalNotification', 'deviceready', []);
exports.exec('deviceready');
});
// Called before 'deviceready' event
channel.onCordovaReady.subscribe(function () {
// Set launchDetails object
exports.exec('launchDetails');
// Device plugin is ready now
channel.onCordovaInfoReady.subscribe(function () {
// Merge platform specifics into defaults
......
......@@ -76,6 +76,12 @@ var app = {
document.getElementById('multiple_nots').onclick = app.multipleNots;
document.getElementById('notifications').onclick = app.notifications;
document.getElementById('defaults').onclick = app.setDefaultTitle;
var details = cordova.plugins.notification.local.launchDetails;
if (details) {
alert('Launched by notification with ID ' + details.id);
}
},
// Check permissions to read accounts
hasPermission: function () {
......@@ -157,12 +163,20 @@ var app = {
actionGroupId: 'like-dislike',
actions: [{
id: 'like',
type: 'button',
title: 'Like',
launch: true
},{
id: 'dislike',
type: 'button',
title: 'Dislike',
ui: 'decline'
},{
id: 'feedback',
type: 'input',
title: 'Feedback',
emptyText: 'Enter feedback',
submitTitle: 'Send'
}]
});
},
......@@ -272,37 +286,45 @@ var app = {
// Listen for events
bindNotificationEvents: function () {
cordova.plugins.notification.local.on('schedule', function (obj) {
console.log('onschedule', arguments);
console.log('schedule', arguments);
// showToast('scheduled: ' + obj.id);
});
cordova.plugins.notification.local.on('update', function (obj) {
console.log('onupdate', arguments);
console.log('update', arguments);
// showToast('updated: ' + obj.id);
});
cordova.plugins.notification.local.on('trigger', function (obj) {
console.log('ontrigger', arguments);
console.log('trigger', arguments);
showToast('triggered: ' + obj.id);
});
cordova.plugins.notification.local.on('click', function (obj) {
console.log('onclick', arguments);
console.log('click', arguments);
showToast('clicked: ' + obj.id);
});
cordova.plugins.notification.local.on('cancel', function (obj) {
console.log('oncancel', arguments);
console.log('cancel', arguments);
// showToast('canceled: ' + obj.id);
});
cordova.plugins.notification.local.on('clear', function (obj) {
console.log('onclear', arguments);
console.log('clear', arguments);
showToast('cleared: ' + obj.id);
});
cordova.plugins.notification.local.on('cancelall', function () {
console.log('oncancelall', arguments);
console.log('cancelall', arguments);
// showToast('canceled all');
});
cordova.plugins.notification.local.on('clearall', function () {
console.log('onclearall', arguments);
console.log('clearall', arguments);
// showToast('cleared all');
});
cordova.plugins.notification.local.on('like', function () {
console.log('like', arguments);
showToast('liked');
});
cordova.plugins.notification.local.on('dislike', function () {
console.log('dislike', arguments);
showToast('disliked');
});
}
};
......
......@@ -22,6 +22,7 @@ var exec = require('cordova/exec'),
// Default values
exports._defaults = {
id: 0,
type: 'normal',
text: '',
title: '',
sound: 'res://platform_default',
......@@ -55,6 +56,8 @@ exports.applyPlatformSpecificOptions = function () {
break;
case 'iOS':
defaults.attachments = undefined;
defaults.region = undefined;
defaults.radius = undefined;
break;
}
};
......@@ -303,11 +306,13 @@ exports.exec = function (action, args, callback, scope) {
channel.deviceready.subscribe(function () {
// Device is ready now, the listeners are registered
// and all queued events can be executed.
exec(null, null, 'LocalNotification', 'deviceready', []);
exports.exec('deviceready');
});
// Called before 'deviceready' event
channel.onCordovaReady.subscribe(function () {
// Set launchDetails object
exports.exec('launchDetails');
// Device plugin is ready now
channel.onCordovaInfoReady.subscribe(function () {
// Merge platform specifics into defaults
......
......@@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2013-2015 appPlant UG, Inc.
Copyright 2013 appPlant GmbH
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......
......@@ -54,6 +54,7 @@
</config-file>
<framework src="UserNotifications.framework" />
<framework src="CoreLocation.framework" />
<header-file src="src/ios/APPLocalNotification.h" />
<source-file src="src/ios/APPLocalNotification.m" />
......
/*
* Copyright (c) 2013 by appPlant GmbH. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import <Cordova/CDVPlugin.h>
......@@ -27,6 +21,8 @@
@interface APPLocalNotification : CDVPlugin <UNUserNotificationCenterDelegate>
// Set launchDetails object
- (void) launchDetails:(CDVInvokedUrlCommand*)command;
// Execute all queued events
- (void) deviceready:(CDVInvokedUrlCommand*)command;
......
/*
* Copyright (c) 2013 by appPlant GmbH. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPLocalNotification.h"
......@@ -32,6 +26,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
......@@ -44,6 +39,27 @@
#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.
*
* @return [ Void ]
......@@ -512,10 +528,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 +549,7 @@
UNNotificationRequest* request = notification.request;
[_center addNotificationCategory:notification.category];
[_center addNotificationRequest:request withCompletionHandler:^(NSError* e) {
__strong APPLocalNotification* strongSelf = weakSelf;
[strongSelf fireEvent:@"add" notification:request];
......@@ -583,6 +599,8 @@
NSString* action = response.actionIdentifier;
NSString* event = action;
completionHandler();
if ([action isEqualToString:UNNotificationDefaultActionIdentifier]) {
event = @"click";
} else
......@@ -590,9 +608,15 @@
event = @"clear";
}
[self fireEvent:event notification:notification];
if (!deviceready && [event isEqualToString:@"click"]) {
_launchDetails = @[notification.options.id, event];
}
completionHandler();
if (![event isEqualToString:@"clear"]) {
[self fireEvent:@"clear" notification:notification];
}
[self fireEvent:event notification:notification];
}
#pragma mark -
......@@ -663,12 +687,12 @@
- (void) fireEvent:(NSString*)event
notification:(UNNotificationRequest*)request
{
NSString* js;
NSString* appState = [self applicationState];
NSString* params = [NSString stringWithFormat:@"\"%@\"", appState];
NSString *js;
NSString *appState = [self applicationState];
NSString *params = [NSString stringWithFormat:@"\"%@\"", appState];
if (request) {
NSString* args = [request encodeToJSON];
NSString *args = [request encodeToJSON];
params = [NSString stringWithFormat:@"%@,'%@'", args, appState];
}
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPNotificationOptions.h"
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPNotificationContent.h"
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
@import UserNotifications;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,13 +13,12 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPNotificationOptions.h"
#import "UNUserNotificationCenter+APPLocalNotification.h"
@import CoreLocation;
@import UserNotifications;
@interface APPNotificationOptions ()
......@@ -52,7 +47,7 @@
self = [self init];
self.dict = dictionary;
[self actions];
return self;
......@@ -62,6 +57,18 @@
#pragma mark Properties
/**
* The type for the notification.
*
* @return [ NSString* ]
*/
- (NSString*) type
{
NSString* type = [dict objectForKey:@"type"];
return type.length ? type : @"normal";
}
/**
* The ID for the notification.
*
* @return [ NSNumber* ]
......@@ -123,7 +130,7 @@
- (NSNumber*) badge
{
id value = [dict objectForKey:@"badge"];
return (value == NULL) ? NULL : [NSNumber numberWithInt:[value intValue]];
}
......@@ -135,7 +142,7 @@
- (NSString*) categoryId
{
NSString* value = [dict objectForKey:@"actionGroupId"];
return value.length ? value : kAPPGeneralCategory;
}
......@@ -175,10 +182,10 @@
{
NSArray* paths = [dict objectForKey:@"attachments"];
NSMutableArray* attachments = [[NSMutableArray alloc] init];
if (!paths)
return attachments;
for (NSString* path in paths) {
NSURL* url = [self urlForAttachmentPath:path];
......@@ -187,12 +194,12 @@
URL:url
options:NULL
error:NULL];
if (attachment) {
[attachments addObject:attachment];
}
}
return attachments;
}
......@@ -205,35 +212,57 @@
{
NSArray* items = [dict objectForKey:@"actions"];
NSMutableArray* actions = [[NSMutableArray alloc] init];
if (!items)
return actions;
for (NSDictionary* item in items) {
NSString* id = [item objectForKey:@"id"];
NSString* title = [item objectForKey:@"title"];
NSString* type = [item objectForKey:@"type"];
UNNotificationActionOptions options = UNNotificationActionOptionNone;
UNNotificationAction* action;
if ([[item objectForKey:@"launch"] boolValue]) {
options = UNNotificationActionOptionForeground;
}
if ([[item objectForKey:@"ui"] isEqualToString:@"decline"]) {
options = options | UNNotificationActionOptionDestructive;
}
if ([[item objectForKey:@"needsAuth"] boolValue]) {
options = options | UNNotificationActionOptionAuthenticationRequired;
}
UNNotificationAction* action;
action = [UNNotificationAction actionWithIdentifier:id
title:title
options:options];
[actions addObject:action];
if ([type isEqualToString:@"input"]) {
NSString* submitTitle = [item objectForKey:@"submitTitle"];
NSString* placeholder = [item objectForKey:@"emptyText"];
if (!submitTitle.length) {
submitTitle = @"Submit";
}
action = [UNTextInputNotificationAction actionWithIdentifier:id
title:title
options:options
textInputButtonTitle:submitTitle
textInputPlaceholder:placeholder];
} else
if (!type.length || [type isEqualToString:@"button"]) {
action = [UNNotificationAction actionWithIdentifier:id
title:title
options:options];
} else {
NSLog(@"Unknown action type: %@", type);
}
if (action) {
[actions addObject:action];
}
}
return actions;
}
......@@ -247,6 +276,14 @@
*/
- (UNNotificationTrigger*) trigger
{
NSString* type = [self type];
if ([type isEqualToString:@"location"])
return [self triggerWithRegion];
if (![type isEqualToString:@"normal"])
NSLog(@"Unknown type: %@", type);
if ([self isRepeating])
return [self repeatingTrigger];
......@@ -283,7 +320,7 @@
{
double timestamp = [[dict objectForKey:@"at"]
doubleValue];
return [NSDate dateWithTimeIntervalSince1970:timestamp];
}
......@@ -326,12 +363,12 @@
id every = [dict objectForKey:@"every"];
if ([every isKindOfClass:NSString.class])
return [self repeatingTriggerWithDateMatchingComponents];
return [self triggerWithDateMatchingComponents];
if ([every isKindOfClass:NSDictionary.class])
return [self repeatingTriggerWithCustomDateMatchingComponents];
return [self triggerWithCustomDateMatchingComponents];
return [self repeatingTriggerWithTimeInterval];
return [self triggerWithTimeInterval];
}
/**
......@@ -339,7 +376,7 @@
*
* @return [ UNTimeIntervalNotificationTrigger* ]
*/
- (UNTimeIntervalNotificationTrigger*) repeatingTriggerWithTimeInterval
- (UNTimeIntervalNotificationTrigger*) triggerWithTimeInterval
{
long interval = [[dict objectForKey:@"every"] longValue];
......@@ -357,7 +394,7 @@
*
* @return [ UNCalendarNotificationTrigger* ]
*/
- (UNCalendarNotificationTrigger*) repeatingTriggerWithDateMatchingComponents
- (UNCalendarNotificationTrigger*) triggerWithDateMatchingComponents
{
NSCalendar* cal = [[NSCalendar alloc]
initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
......@@ -376,7 +413,7 @@
*
* @return [ UNCalendarNotificationTrigger* ]
*/
- (UNCalendarNotificationTrigger*) repeatingTriggerWithCustomDateMatchingComponents
- (UNCalendarNotificationTrigger*) triggerWithCustomDateMatchingComponents
{
NSCalendar* cal = [[NSCalendar alloc]
initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
......@@ -391,6 +428,30 @@
}
/**
* A repeating trigger based on a location region.
*
* @return [ UNLocationNotificationTrigger* ]
*/
- (UNLocationNotificationTrigger*) triggerWithRegion
{
NSArray* center = [dict objectForKey:@"center"];
double radius = [[dict objectForKey:@"radius"] doubleValue];
CLLocationCoordinate2D coord =
CLLocationCoordinate2DMake([center[0] doubleValue], [center[1] doubleValue]);
CLCircularRegion* region =
[[CLCircularRegion alloc] initWithCenter:coord
radius:radius
identifier:self.identifier];
region.notifyOnEntry = [[dict objectForKey:@"notifyOnEntry"] boolValue];
region.notifyOnExit = [[dict objectForKey:@"notifyOnExit"] boolValue];
return [UNLocationNotificationTrigger triggerWithRegion:region repeats:YES];
}
/**
* The time interval between the next fire date and now.
*
* @return [ double ]
......@@ -580,7 +641,7 @@
if ([path isEqualToString:@"res://icon"]) {
path = @"res://AppIcon60x60@3x.png";
}
NSString* absPath;
absPath = [path stringByReplacingOccurrencesOfString:@"res:/"
withString:@""];
......@@ -606,7 +667,7 @@
NSFileManager* fm = [NSFileManager defaultManager];
NSBundle* mainBundle = [NSBundle mainBundle];
NSString* bundlePath = [mainBundle bundlePath];
NSString* absPath;
absPath = [path stringByReplacingOccurrencesOfString:@"file:/"
withString:@"/www"];
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPNotificationOptions.h"
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPNotificationOptions.h"
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPNotificationContent.h"
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -17,8 +13,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "UNUserNotificationCenter+APPLocalNotification.h"
......@@ -62,17 +56,17 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
{
if (!category)
return;
[self getNotificationCategoriesWithCompletionHandler:^(NSSet<UNNotificationCategory *> *set) {
NSMutableSet* categories = [NSMutableSet setWithSet:set];
for (UNNotificationCategory* item in categories) {
if ([category.identifier isEqualToString:item.identifier]) {
[categories removeObject:item];
break;
}
}
[categories addObject:category];
[self setNotificationCategories:categories];
}];
......
......@@ -21,6 +21,7 @@ var exec = require('cordova/exec'),
// Default values
exports._defaults = {
id: 0,
type: 'normal',
text: '',
title: '',
sound: 'res://platform_default',
......@@ -54,6 +55,8 @@ exports.applyPlatformSpecificOptions = function () {
break;
case 'iOS':
defaults.attachments = undefined;
defaults.region = undefined;
defaults.radius = undefined;
break;
}
};
......@@ -302,11 +305,13 @@ exports.exec = function (action, args, callback, scope) {
channel.deviceready.subscribe(function () {
// Device is ready now, the listeners are registered
// and all queued events can be executed.
exec(null, null, 'LocalNotification', 'deviceready', []);
exports.exec('deviceready');
});
// Called before 'deviceready' event
channel.onCordovaReady.subscribe(function () {
// Set launchDetails object
exports.exec('launchDetails');
// Device plugin is ready now
channel.onCordovaInfoReady.subscribe(function () {
// Merge platform specifics into defaults
......
......@@ -76,6 +76,12 @@ var app = {
document.getElementById('multiple_nots').onclick = app.multipleNots;
document.getElementById('notifications').onclick = app.notifications;
document.getElementById('defaults').onclick = app.setDefaultTitle;
var details = cordova.plugins.notification.local.launchDetails;
if (details) {
alert('Launched by notification with ID ' + details.id);
}
},
// Check permissions to read accounts
hasPermission: function () {
......@@ -157,12 +163,20 @@ var app = {
actionGroupId: 'like-dislike',
actions: [{
id: 'like',
type: 'button',
title: 'Like',
launch: true
},{
id: 'dislike',
type: 'button',
title: 'Dislike',
ui: 'decline'
},{
id: 'feedback',
type: 'input',
title: 'Feedback',
emptyText: 'Enter feedback',
submitTitle: 'Send'
}]
});
},
......@@ -272,37 +286,45 @@ var app = {
// Listen for events
bindNotificationEvents: function () {
cordova.plugins.notification.local.on('schedule', function (obj) {
console.log('onschedule', arguments);
console.log('schedule', arguments);
// showToast('scheduled: ' + obj.id);
});
cordova.plugins.notification.local.on('update', function (obj) {
console.log('onupdate', arguments);
console.log('update', arguments);
// showToast('updated: ' + obj.id);
});
cordova.plugins.notification.local.on('trigger', function (obj) {
console.log('ontrigger', arguments);
console.log('trigger', arguments);
showToast('triggered: ' + obj.id);
});
cordova.plugins.notification.local.on('click', function (obj) {
console.log('onclick', arguments);
console.log('click', arguments);
showToast('clicked: ' + obj.id);
});
cordova.plugins.notification.local.on('cancel', function (obj) {
console.log('oncancel', arguments);
console.log('cancel', arguments);
// showToast('canceled: ' + obj.id);
});
cordova.plugins.notification.local.on('clear', function (obj) {
console.log('onclear', arguments);
console.log('clear', arguments);
showToast('cleared: ' + obj.id);
});
cordova.plugins.notification.local.on('cancelall', function () {
console.log('oncancelall', arguments);
console.log('cancelall', arguments);
// showToast('canceled all');
});
cordova.plugins.notification.local.on('clearall', function () {
console.log('onclearall', arguments);
console.log('clearall', arguments);
// showToast('cleared all');
});
cordova.plugins.notification.local.on('like', function () {
console.log('like', arguments);
showToast('liked');
});
cordova.plugins.notification.local.on('dislike', function () {
console.log('dislike', arguments);
showToast('disliked');
});
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment