Commit 9c65b6c2 by Sebastián Katzer

Update to latest dev

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