Commit e0c0d588 by Sebastián Katzer

Update example

parent e071e96a
...@@ -67,7 +67,8 @@ exports._defaults = { ...@@ -67,7 +67,8 @@ exports._defaults = {
badge: -1, badge: -1,
id: '0', id: '0',
json: '', json: '',
repeat: '' repeat: '',
date: undefined
}; };
...@@ -208,6 +209,29 @@ exports.cancelAll = function (callback, scope) { ...@@ -208,6 +209,29 @@ exports.cancelAll = function (callback, scope) {
}; };
/** /**
* Check if a notification with an ID exists.
*
* @param {String} id
* The ID of the notification
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports.exist = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('exist', notId, callback, scope);
};
/**
* Alias for `exist`.
*/
exports.exists = function () {
this.exist.apply(this, arguments);
};
/**
* Check if a notification with an ID is scheduled. * Check if a notification with an ID is scheduled.
* *
* @param {String} id * @param {String} id
...@@ -240,7 +264,26 @@ exports.isTriggered = function (id, callback, scope) { ...@@ -240,7 +264,26 @@ exports.isTriggered = function (id, callback, scope) {
}; };
/** /**
* List all currently pending notifications. * List all local notification IDs.
*
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports.getAllIds = function (callback, scope) {
this.exec('getAllIds', null, callback, scope);
};
/**
* Alias for `getAllIds`.
*/
exports.getIds = function () {
this.getAllIds.apply(this, arguments);
};
/**
* List all scheduled notification IDs.
* *
* @param {Function} callback * @param {Function} callback
* A callback function to be called with the list * A callback function to be called with the list
...@@ -252,7 +295,7 @@ exports.getScheduledIds = function (callback, scope) { ...@@ -252,7 +295,7 @@ exports.getScheduledIds = function (callback, scope) {
}; };
/** /**
* List all triggered notifications. * List all triggered notification IDs.
* *
* @param {Function} callback * @param {Function} callback
* A callback function to be called with the list * A callback function to be called with the list
...@@ -264,7 +307,50 @@ exports.getTriggeredIds = function (callback, scope) { ...@@ -264,7 +307,50 @@ exports.getTriggeredIds = function (callback, scope) {
}; };
/** /**
* List all properties for given scheduled notifications. * Property list for given local notifications.
* If called without IDs, all notification will be returned.
*
* @param {Number[]?} ids
* Set of notification IDs
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports.get = function () {
var args = Array.apply(null, arguments);
if (typeof args[0] == 'function') {
args.unshift([]);
}
var ids = args[0],
callback = args[1],
scope = args[2];
if (!Array.isArray(ids)) {
ids = [ids];
}
ids = this.convertIds(ids);
this.exec('getAll', ids, callback, scope);
};
/**
* Property list for all local notifications.
*
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports.getAll = function (callback, scope) {
this.exec('getAll', null, callback, scope);
};
/**
* Property list for given scheduled notifications.
* If called without IDs, all notification will be returned. * If called without IDs, all notification will be returned.
* *
* @param {Number[]?} ids * @param {Number[]?} ids
...@@ -307,7 +393,7 @@ exports.getAllScheduled = function (callback, scope) { ...@@ -307,7 +393,7 @@ exports.getAllScheduled = function (callback, scope) {
}; };
/** /**
* List all properties for given triggered notifications. * Property list for given triggered notifications.
* If called without IDs, all notification will be returned. * If called without IDs, all notification will be returned.
* *
* @param {Number[]?} ids * @param {Number[]?} ids
...@@ -634,7 +720,9 @@ exports.convertIds = function (ids) { ...@@ -634,7 +720,9 @@ exports.convertIds = function (ids) {
exports.getValueFor = function (options) { exports.getValueFor = function (options) {
var keys = Array.apply(null, arguments).slice(1); var keys = Array.apply(null, arguments).slice(1);
for (var key in keys) { for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (options.hasOwnProperty(key)) { if (options.hasOwnProperty(key)) {
return options[key]; return options[key];
} }
......
...@@ -5,12 +5,10 @@ ...@@ -5,12 +5,10 @@
}; };
objectVersion = 46; objectVersion = 46;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
0B33C5FC1B224A91B96FDE79 /* CDVDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 212EBD1D7BCB4409838CD818 /* CDVDevice.m */; }; 0B33C5FC1B224A91B96FDE79 /* CDVDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 212EBD1D7BCB4409838CD818 /* CDVDevice.m */; };
1D3623260D0F684500981E51 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* AppDelegate.m */; }; 1D3623260D0F684500981E51 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* AppDelegate.m */; };
1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
244C5454167242FABDACC376 /* AppDelegate+APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 028AC353A09C4EA79A266646 /* AppDelegate+APPLocalNotification.m */; };
288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; }; 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; };
301BF552109A68D80062928A /* libCordova.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF535109A57CC0062928A /* libCordova.a */; }; 301BF552109A68D80062928A /* libCordova.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF535109A57CC0062928A /* libCordova.a */; };
302D95F114D2391D003F00A1 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 302D95EF14D2391D003F00A1 /* MainViewController.m */; }; 302D95F114D2391D003F00A1 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 302D95EF14D2391D003F00A1 /* MainViewController.m */; };
...@@ -43,13 +41,14 @@ ...@@ -43,13 +41,14 @@
7E7966E51810823500FA85AD /* icon-76@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7E7966DB1810823500FA85AD /* icon-76@2x.png */; }; 7E7966E51810823500FA85AD /* icon-76@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7E7966DB1810823500FA85AD /* icon-76@2x.png */; };
7E7966E61810823500FA85AD /* icon-small.png in Resources */ = {isa = PBXBuildFile; fileRef = 7E7966DC1810823500FA85AD /* icon-small.png */; }; 7E7966E61810823500FA85AD /* icon-small.png in Resources */ = {isa = PBXBuildFile; fileRef = 7E7966DC1810823500FA85AD /* icon-small.png */; };
7E7966E71810823500FA85AD /* icon-small@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7E7966DD1810823500FA85AD /* icon-small@2x.png */; }; 7E7966E71810823500FA85AD /* icon-small@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7E7966DD1810823500FA85AD /* icon-small@2x.png */; };
90D59C90545F4506982554E8 /* APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = EE4654C98F394A8DBDE0AC57 /* APPLocalNotification.m */; };
9E1A68381A55FA1B00FBCA66 /* beep.caf in Resources */ = {isa = PBXBuildFile; fileRef = 9E1A68371A55FA1B00FBCA66 /* beep.caf */; }; 9E1A68381A55FA1B00FBCA66 /* beep.caf in Resources */ = {isa = PBXBuildFile; fileRef = 9E1A68371A55FA1B00FBCA66 /* beep.caf */; };
9E5A62291A52DE07002E41A3 /* (null) in Sources */ = {isa = PBXBuildFile; }; 9E5A62291A52DE07002E41A3 /* (null) in Sources */ = {isa = PBXBuildFile; };
BD757B0D44BE440083918077 /* APPLocalNotificationOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 37095E752E9D455C853BE373 /* APPLocalNotificationOptions.m */; };
D4A0D8761607E02300AEF8BB /* Default-568h@2x~iphone.png in Resources */ = {isa = PBXBuildFile; fileRef = D4A0D8751607E02300AEF8BB /* Default-568h@2x~iphone.png */; }; D4A0D8761607E02300AEF8BB /* Default-568h@2x~iphone.png in Resources */ = {isa = PBXBuildFile; fileRef = D4A0D8751607E02300AEF8BB /* Default-568h@2x~iphone.png */; };
F378B9146F0E46C2BD460ED2 /* UILocalNotification+APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E55360F8342488798514532 /* UILocalNotification+APPLocalNotification.m */; }; DAF1F9AF035A4906A75A27A9 /* APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = AEFD9669D247496E8C313773 /* APPLocalNotification.m */; };
F809B57D91144ACBA4D15DE6 /* UIApplication+APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4288BC92A44887AE839CAE /* UIApplication+APPLocalNotification.m */; }; A41144BE1C02446C962ED8A4 /* APPLocalNotificationOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = B3F526C192724B9983D6DF49 /* APPLocalNotificationOptions.m */; };
0BF965D1A27C4A0EAC8124AB /* AppDelegate+APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A1657722134FF3928150AE /* AppDelegate+APPLocalNotification.m */; };
BAD27C5DAFDB4B068CF508B5 /* UIApplication+APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 4AA2CC6AE1514E5A817FDB77 /* UIApplication+APPLocalNotification.m */; };
862E52E5848F42779B5FE959 /* UILocalNotification+APPLocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 146C149F3066438F805AAEA7 /* UILocalNotification+APPLocalNotification.m */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
...@@ -70,14 +69,12 @@ ...@@ -70,14 +69,12 @@
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
028AC353A09C4EA79A266646 /* AppDelegate+APPLocalNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "AppDelegate+APPLocalNotification.m"; path = "de.appplant.cordova.plugin.local-notification/AppDelegate+APPLocalNotification.m"; sourceTree = "<group>"; };
1D3623240D0F684500981E51 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; 1D3623240D0F684500981E51 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
1D3623250D0F684500981E51 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; }; 1D3623250D0F684500981E51 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
1D6058910D05DD3D006BFB54 /* NotificationExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NotificationExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1D6058910D05DD3D006BFB54 /* NotificationExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NotificationExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
212EBD1D7BCB4409838CD818 /* CDVDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVDevice.m; path = org.apache.cordova.device/CDVDevice.m; sourceTree = "<group>"; }; 212EBD1D7BCB4409838CD818 /* CDVDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVDevice.m; path = org.apache.cordova.device/CDVDevice.m; sourceTree = "<group>"; };
288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
2C2F7D7BF58F46B4ADDA1E7E /* AppDelegate+APPLocalNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "AppDelegate+APPLocalNotification.h"; path = "de.appplant.cordova.plugin.local-notification/AppDelegate+APPLocalNotification.h"; sourceTree = "<group>"; };
301BF52D109A57CC0062928A /* CordovaLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CordovaLib.xcodeproj; path = CordovaLib/CordovaLib.xcodeproj; sourceTree = "<group>"; }; 301BF52D109A57CC0062928A /* CordovaLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CordovaLib.xcodeproj; path = CordovaLib/CordovaLib.xcodeproj; sourceTree = "<group>"; };
301BF56E109A69640062928A /* www */ = {isa = PBXFileReference; lastKnownFileType = folder; path = www; sourceTree = SOURCE_ROOT; }; 301BF56E109A69640062928A /* www */ = {isa = PBXFileReference; lastKnownFileType = folder; path = www; sourceTree = SOURCE_ROOT; };
302D95EE14D2391D003F00A1 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = "<group>"; }; 302D95EE14D2391D003F00A1 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = "<group>"; };
...@@ -99,11 +96,8 @@ ...@@ -99,11 +96,8 @@
30C1856519D5FC0A00212699 /* icon-60@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-60@3x.png"; sourceTree = "<group>"; }; 30C1856519D5FC0A00212699 /* icon-60@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-60@3x.png"; sourceTree = "<group>"; };
30FC414816E50CA1004E6F35 /* icon-72@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-72@2x.png"; sourceTree = "<group>"; }; 30FC414816E50CA1004E6F35 /* icon-72@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-72@2x.png"; sourceTree = "<group>"; };
32CA4F630368D1EE00C91783 /* NotificationExample-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NotificationExample-Prefix.pch"; sourceTree = "<group>"; }; 32CA4F630368D1EE00C91783 /* NotificationExample-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NotificationExample-Prefix.pch"; sourceTree = "<group>"; };
37095E752E9D455C853BE373 /* APPLocalNotificationOptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = APPLocalNotificationOptions.m; path = "de.appplant.cordova.plugin.local-notification/APPLocalNotificationOptions.m"; sourceTree = "<group>"; };
3C888438876C480D8B36E11A /* APPBackgroundMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = APPBackgroundMode.h; path = "de.appplant.cordova.plugin.background-mode/APPBackgroundMode.h"; sourceTree = "<group>"; }; 3C888438876C480D8B36E11A /* APPBackgroundMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = APPBackgroundMode.h; path = "de.appplant.cordova.plugin.background-mode/APPBackgroundMode.h"; sourceTree = "<group>"; };
4C4288BC92A44887AE839CAE /* UIApplication+APPLocalNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIApplication+APPLocalNotification.m"; path = "de.appplant.cordova.plugin.local-notification/UIApplication+APPLocalNotification.m"; sourceTree = "<group>"; };
5B1594DC16A7569C00FEF299 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; }; 5B1594DC16A7569C00FEF299 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
5E55360F8342488798514532 /* UILocalNotification+APPLocalNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UILocalNotification+APPLocalNotification.m"; path = "de.appplant.cordova.plugin.local-notification/UILocalNotification+APPLocalNotification.m"; sourceTree = "<group>"; };
7E7966D41810823500FA85AD /* icon-40.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-40.png"; sourceTree = "<group>"; }; 7E7966D41810823500FA85AD /* icon-40.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-40.png"; sourceTree = "<group>"; };
7E7966D51810823500FA85AD /* icon-40@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-40@2x.png"; sourceTree = "<group>"; }; 7E7966D51810823500FA85AD /* icon-40@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-40@2x.png"; sourceTree = "<group>"; };
7E7966D61810823500FA85AD /* icon-50.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-50.png"; sourceTree = "<group>"; }; 7E7966D61810823500FA85AD /* icon-50.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-50.png"; sourceTree = "<group>"; };
...@@ -116,18 +110,23 @@ ...@@ -116,18 +110,23 @@
7E7966DD1810823500FA85AD /* icon-small@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-small@2x.png"; sourceTree = "<group>"; }; 7E7966DD1810823500FA85AD /* icon-small@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-small@2x.png"; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* NotificationExample-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "NotificationExample-Info.plist"; path = "../NotificationExample-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; }; 8D1107310486CEB800E47090 /* NotificationExample-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "NotificationExample-Info.plist"; path = "../NotificationExample-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
9E1A68371A55FA1B00FBCA66 /* beep.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = beep.caf; sourceTree = "<group>"; }; 9E1A68371A55FA1B00FBCA66 /* beep.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = beep.caf; sourceTree = "<group>"; };
B22193F3CC42466498BF03A8 /* APPLocalNotificationOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = APPLocalNotificationOptions.h; path = "de.appplant.cordova.plugin.local-notification/APPLocalNotificationOptions.h"; sourceTree = "<group>"; };
C37D37FB86E04E16BA8047EE /* APPLocalNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = APPLocalNotification.h; path = "de.appplant.cordova.plugin.local-notification/APPLocalNotification.h"; sourceTree = "<group>"; };
CAD9B6E7C8424F74AF0AA068 /* UILocalNotification+APPLocalNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UILocalNotification+APPLocalNotification.h"; path = "de.appplant.cordova.plugin.local-notification/UILocalNotification+APPLocalNotification.h"; sourceTree = "<group>"; };
D4A0D8751607E02300AEF8BB /* Default-568h@2x~iphone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x~iphone.png"; sourceTree = "<group>"; }; D4A0D8751607E02300AEF8BB /* Default-568h@2x~iphone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x~iphone.png"; sourceTree = "<group>"; };
DDDFCE9D76CA4692A1F4A984 /* APPBackgroundMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = APPBackgroundMode.m; path = "de.appplant.cordova.plugin.background-mode/APPBackgroundMode.m"; sourceTree = "<group>"; }; DDDFCE9D76CA4692A1F4A984 /* APPBackgroundMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = APPBackgroundMode.m; path = "de.appplant.cordova.plugin.background-mode/APPBackgroundMode.m"; sourceTree = "<group>"; };
E02030E711134A5D8215D2F0 /* appbeep.wav */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = unknown; path = appbeep.wav; sourceTree = "<group>"; }; E02030E711134A5D8215D2F0 /* appbeep.wav */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = unknown; path = appbeep.wav; sourceTree = "<group>"; };
EB87FDF31871DA8E0020F90C /* www */ = {isa = PBXFileReference; lastKnownFileType = folder; name = www; path = ../../www; sourceTree = "<group>"; }; EB87FDF31871DA8E0020F90C /* www */ = {isa = PBXFileReference; lastKnownFileType = folder; name = www; path = ../../www; sourceTree = "<group>"; };
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>"; };
EE4654C98F394A8DBDE0AC57 /* APPLocalNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = APPLocalNotification.m; path = "de.appplant.cordova.plugin.local-notification/APPLocalNotification.m"; sourceTree = "<group>"; };
EF7CC58EF6424BB183C2CE58 /* UIApplication+APPLocalNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIApplication+APPLocalNotification.h"; path = "de.appplant.cordova.plugin.local-notification/UIApplication+APPLocalNotification.h"; sourceTree = "<group>"; };
F042F1C3B49D4E2699FF5E1D /* CDVDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVDevice.h; path = org.apache.cordova.device/CDVDevice.h; sourceTree = "<group>"; }; F042F1C3B49D4E2699FF5E1D /* CDVDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVDevice.h; path = org.apache.cordova.device/CDVDevice.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>"; };
AEFD9669D247496E8C313773 /* APPLocalNotification.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "APPLocalNotification.m"; path = "de.appplant.cordova.plugin.local-notification/APPLocalNotification.m"; sourceTree = "<group>"; fileEncoding = 4; };
B3F526C192724B9983D6DF49 /* APPLocalNotificationOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "APPLocalNotificationOptions.m"; path = "de.appplant.cordova.plugin.local-notification/APPLocalNotificationOptions.m"; sourceTree = "<group>"; fileEncoding = 4; };
D2A1657722134FF3928150AE /* AppDelegate+APPLocalNotification.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "AppDelegate+APPLocalNotification.m"; path = "de.appplant.cordova.plugin.local-notification/AppDelegate+APPLocalNotification.m"; sourceTree = "<group>"; fileEncoding = 4; };
4AA2CC6AE1514E5A817FDB77 /* UIApplication+APPLocalNotification.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "UIApplication+APPLocalNotification.m"; path = "de.appplant.cordova.plugin.local-notification/UIApplication+APPLocalNotification.m"; sourceTree = "<group>"; fileEncoding = 4; };
146C149F3066438F805AAEA7 /* UILocalNotification+APPLocalNotification.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "UILocalNotification+APPLocalNotification.m"; path = "de.appplant.cordova.plugin.local-notification/UILocalNotification+APPLocalNotification.m"; sourceTree = "<group>"; fileEncoding = 4; };
2CD30643192E4C1589D25D5B /* APPLocalNotification.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "APPLocalNotification.h"; path = "de.appplant.cordova.plugin.local-notification/APPLocalNotification.h"; sourceTree = "<group>"; fileEncoding = 4; };
BEE99D9715304787A75D6718 /* APPLocalNotificationOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "APPLocalNotificationOptions.h"; path = "de.appplant.cordova.plugin.local-notification/APPLocalNotificationOptions.h"; sourceTree = "<group>"; fileEncoding = 4; };
5B7C3D42FBD94C98A94C6841 /* AppDelegate+APPLocalNotification.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "AppDelegate+APPLocalNotification.h"; path = "de.appplant.cordova.plugin.local-notification/AppDelegate+APPLocalNotification.h"; sourceTree = "<group>"; fileEncoding = 4; };
C424392873644865942AFA37 /* UIApplication+APPLocalNotification.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "UIApplication+APPLocalNotification.h"; path = "de.appplant.cordova.plugin.local-notification/UIApplication+APPLocalNotification.h"; sourceTree = "<group>"; fileEncoding = 4; };
76B9FA47D6D8451FB98EE9BB /* UILocalNotification+APPLocalNotification.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "UILocalNotification+APPLocalNotification.h"; path = "de.appplant.cordova.plugin.local-notification/UILocalNotification+APPLocalNotification.h"; sourceTree = "<group>"; fileEncoding = 4; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -231,16 +230,16 @@ ...@@ -231,16 +230,16 @@
212EBD1D7BCB4409838CD818 /* CDVDevice.m */, 212EBD1D7BCB4409838CD818 /* CDVDevice.m */,
3C888438876C480D8B36E11A /* APPBackgroundMode.h */, 3C888438876C480D8B36E11A /* APPBackgroundMode.h */,
DDDFCE9D76CA4692A1F4A984 /* APPBackgroundMode.m */, DDDFCE9D76CA4692A1F4A984 /* APPBackgroundMode.m */,
C37D37FB86E04E16BA8047EE /* APPLocalNotification.h */, AEFD9669D247496E8C313773 /* APPLocalNotification.m */,
EE4654C98F394A8DBDE0AC57 /* APPLocalNotification.m */, B3F526C192724B9983D6DF49 /* APPLocalNotificationOptions.m */,
B22193F3CC42466498BF03A8 /* APPLocalNotificationOptions.h */, D2A1657722134FF3928150AE /* AppDelegate+APPLocalNotification.m */,
37095E752E9D455C853BE373 /* APPLocalNotificationOptions.m */, 4AA2CC6AE1514E5A817FDB77 /* UIApplication+APPLocalNotification.m */,
2C2F7D7BF58F46B4ADDA1E7E /* AppDelegate+APPLocalNotification.h */, 146C149F3066438F805AAEA7 /* UILocalNotification+APPLocalNotification.m */,
028AC353A09C4EA79A266646 /* AppDelegate+APPLocalNotification.m */, 2CD30643192E4C1589D25D5B /* APPLocalNotification.h */,
CAD9B6E7C8424F74AF0AA068 /* UILocalNotification+APPLocalNotification.h */, BEE99D9715304787A75D6718 /* APPLocalNotificationOptions.h */,
5E55360F8342488798514532 /* UILocalNotification+APPLocalNotification.m */, 5B7C3D42FBD94C98A94C6841 /* AppDelegate+APPLocalNotification.h */,
EF7CC58EF6424BB183C2CE58 /* UIApplication+APPLocalNotification.h */, C424392873644865942AFA37 /* UIApplication+APPLocalNotification.h */,
4C4288BC92A44887AE839CAE /* UIApplication+APPLocalNotification.m */, 76B9FA47D6D8451FB98EE9BB /* UILocalNotification+APPLocalNotification.h */,
); );
name = Plugins; name = Plugins;
path = NotificationExample/Plugins; path = NotificationExample/Plugins;
...@@ -430,11 +429,11 @@ ...@@ -430,11 +429,11 @@
9E5A62291A52DE07002E41A3 /* (null) in Sources */, 9E5A62291A52DE07002E41A3 /* (null) in Sources */,
0B33C5FC1B224A91B96FDE79 /* CDVDevice.m in Sources */, 0B33C5FC1B224A91B96FDE79 /* CDVDevice.m in Sources */,
3DBE1CCC022B412AA9E356AF /* APPBackgroundMode.m in Sources */, 3DBE1CCC022B412AA9E356AF /* APPBackgroundMode.m in Sources */,
90D59C90545F4506982554E8 /* APPLocalNotification.m in Sources */, DAF1F9AF035A4906A75A27A9 /* APPLocalNotification.m in Sources */,
BD757B0D44BE440083918077 /* APPLocalNotificationOptions.m in Sources */, A41144BE1C02446C962ED8A4 /* APPLocalNotificationOptions.m in Sources */,
244C5454167242FABDACC376 /* AppDelegate+APPLocalNotification.m in Sources */, 0BF965D1A27C4A0EAC8124AB /* AppDelegate+APPLocalNotification.m in Sources */,
F809B57D91144ACBA4D15DE6 /* UIApplication+APPLocalNotification.m in Sources */, BAD27C5DAFDB4B068CF508B5 /* UIApplication+APPLocalNotification.m in Sources */,
F378B9146F0E46C2BD460ED2 /* UILocalNotification+APPLocalNotification.m in Sources */, 862E52E5848F42779B5FE959 /* UILocalNotification+APPLocalNotification.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
......
...@@ -2,4 +2,38 @@ ...@@ -2,4 +2,38 @@
<Bucket <Bucket
type = "1" type = "1"
version = "2.0"> version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "NotificationExample/Plugins/de.appplant.cordova.plugin.local-notification/APPLocalNotification.m"
timestampString = "443052948.14449"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "332"
endingLineNumber = "332"
landmarkName = "-getScheduled:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "NotificationExample/Plugins/de.appplant.cordova.plugin.local-notification/CDVCommandDelegateImpl+APPLocalNotification.m"
timestampString = "443053439.054207"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "76"
endingLineNumber = "76"
landmarkName = "-callSuccessFrom:withMessageAsArray:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket> </Bucket>
...@@ -172,18 +172,18 @@ ...@@ -172,18 +172,18 @@
[self.commandDelegate runInBackground:^{ [self.commandDelegate runInBackground:^{
NSString* id = [[command arguments] NSString* id = [[command arguments]
objectAtIndex:0]; objectAtIndex:0];
CDVPluginResult* result; CDVPluginResult* result;
UILocalNotification* notification; UILocalNotification* notification;
notification = [[UIApplication sharedApplication] notification = [[UIApplication sharedApplication]
localNotificationWithId:id]; localNotificationWithId:id];
bool exists = notification != NULL; bool exists = notification != NULL;
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsBool:exists]; messageAsBool:exists];
[self.commandDelegate sendPluginResult:result [self.commandDelegate sendPluginResult:result
callbackId:command.callbackId]; callbackId:command.callbackId];
}]; }];
...@@ -253,13 +253,13 @@ ...@@ -253,13 +253,13 @@
[self.commandDelegate runInBackground:^{ [self.commandDelegate runInBackground:^{
CDVPluginResult* result; CDVPluginResult* result;
NSArray* notIds; NSArray* notIds;
notIds = [[UIApplication sharedApplication] notIds = [[UIApplication sharedApplication]
localNotificationIds]; localNotificationIds];
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsArray:notIds]; messageAsArray:notIds];
[self.commandDelegate sendPluginResult:result [self.commandDelegate sendPluginResult:result
callbackId:command.callbackId]; callbackId:command.callbackId];
}]; }];
...@@ -317,7 +317,7 @@ ...@@ -317,7 +317,7 @@
NSArray* ids = command.arguments; NSArray* ids = command.arguments;
NSArray* notifications; NSArray* notifications;
CDVPluginResult* result; CDVPluginResult* result;
if (ids.count == 0) { if (ids.count == 0) {
notifications = [[UIApplication sharedApplication] notifications = [[UIApplication sharedApplication]
localNotificationOptions]; localNotificationOptions];
...@@ -325,10 +325,10 @@ ...@@ -325,10 +325,10 @@
notifications = [[UIApplication sharedApplication] notifications = [[UIApplication sharedApplication]
localNotificationOptions:ids]; localNotificationOptions:ids];
} }
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsArray:notifications]; messageAsArray:notifications];
[self.commandDelegate sendPluginResult:result [self.commandDelegate sendPluginResult:result
callbackId:command.callbackId]; callbackId:command.callbackId];
}]; }];
......
...@@ -79,14 +79,14 @@ ...@@ -79,14 +79,14 @@
{ {
NSArray* scheduledNotifications = self.scheduledLocalNotifications; NSArray* scheduledNotifications = self.scheduledLocalNotifications;
NSMutableArray* notifications = [[NSMutableArray alloc] init]; NSMutableArray* notifications = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in scheduledNotifications) for (UILocalNotification* notification in scheduledNotifications)
{ {
if (notification) { if (notification) {
[notifications addObject:notification]; [notifications addObject:notification];
} }
} }
return notifications; return notifications;
} }
...@@ -98,14 +98,14 @@ ...@@ -98,14 +98,14 @@
{ {
NSArray* scheduledNotifications = self.scheduledLocalNotifications; NSArray* scheduledNotifications = self.scheduledLocalNotifications;
NSMutableArray* notifications = [[NSMutableArray alloc] init]; NSMutableArray* notifications = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in scheduledNotifications) for (UILocalNotification* notification in scheduledNotifications)
{ {
if (notification && [notification wasScheduled]) { if (notification && [notification wasScheduled]) {
[notifications addObject:notification]; [notifications addObject:notification];
} }
} }
return notifications; return notifications;
} }
...@@ -136,12 +136,12 @@ ...@@ -136,12 +136,12 @@
{ {
NSArray* notifications = self.localNotifications; NSArray* notifications = self.localNotifications;
NSMutableArray* ids = [[NSMutableArray alloc] init]; NSMutableArray* ids = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in notifications) for (UILocalNotification* notification in notifications)
{ {
[ids addObject:notification.options.id]; [ids addObject:notification.options.id];
} }
return ids; return ids;
} }
...@@ -153,12 +153,12 @@ ...@@ -153,12 +153,12 @@
{ {
NSArray* notifications = self.triggeredLocalNotifications; NSArray* notifications = self.triggeredLocalNotifications;
NSMutableArray* ids = [[NSMutableArray alloc] init]; NSMutableArray* ids = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in notifications) for (UILocalNotification* notification in notifications)
{ {
[ids addObject:notification.options.id]; [ids addObject:notification.options.id];
} }
return ids; return ids;
} }
...@@ -187,14 +187,14 @@ ...@@ -187,14 +187,14 @@
- (UILocalNotification*) localNotificationWithId:(NSString*)id - (UILocalNotification*) localNotificationWithId:(NSString*)id
{ {
NSArray* notifications = self.localNotifications; NSArray* notifications = self.localNotifications;
for (UILocalNotification* notification in notifications) for (UILocalNotification* notification in notifications)
{ {
if ([notification.options.id isEqualToString:id]) { if ([notification.options.id isEqualToString:id]) {
return notification; return notification;
} }
} }
return NULL; return NULL;
} }
...@@ -242,12 +242,12 @@ ...@@ -242,12 +242,12 @@
{ {
NSArray* notifications = self.localNotifications; NSArray* notifications = self.localNotifications;
NSMutableArray* options = [[NSMutableArray alloc] init]; NSMutableArray* options = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in notifications) for (UILocalNotification* notification in notifications)
{ {
[options addObject:notification.userInfo]; [options addObject:notification.userInfo];
} }
return options; return options;
} }
...@@ -274,12 +274,12 @@ ...@@ -274,12 +274,12 @@
{ {
NSArray* notifications = self.triggeredLocalNotifications; NSArray* notifications = self.triggeredLocalNotifications;
NSMutableArray* options = [[NSMutableArray alloc] init]; NSMutableArray* options = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in notifications) for (UILocalNotification* notification in notifications)
{ {
[options addObject:notification.userInfo]; [options addObject:notification.userInfo];
} }
return options; return options;
} }
...@@ -293,16 +293,16 @@ ...@@ -293,16 +293,16 @@
{ {
UILocalNotification* notification; UILocalNotification* notification;
NSMutableArray* options = [[NSMutableArray alloc] init]; NSMutableArray* options = [[NSMutableArray alloc] init];
for (NSString* id in ids) for (NSString* id in ids)
{ {
notification = [self localNotificationWithId:id]; notification = [self localNotificationWithId:id];
if (notification) { if (notification) {
[options addObject:notification.userInfo]; [options addObject:notification.userInfo];
} }
} }
return options; return options;
} }
......
...@@ -150,17 +150,17 @@ static char optionsKey; ...@@ -150,17 +150,17 @@ static char optionsKey;
NSString* json; NSString* json;
NSData* data; NSData* data;
NSMutableDictionary* obj = [self.userInfo mutableCopy]; NSMutableDictionary* obj = [self.userInfo mutableCopy];
[obj removeObjectForKey:@"json"]; [obj removeObjectForKey:@"json"];
[obj removeObjectForKey:@"updatedAt"]; [obj removeObjectForKey:@"updatedAt"];
data = [NSJSONSerialization dataWithJSONObject:obj data = [NSJSONSerialization dataWithJSONObject:obj
options:NSJSONWritingPrettyPrinted options:NSJSONWritingPrettyPrinted
error:Nil]; error:Nil];
json = [[NSString alloc] initWithData:data json = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding]; encoding:NSUTF8StringEncoding];
return [json stringByReplacingOccurrencesOfString:@"\n" return [json stringByReplacingOccurrencesOfString:@"\n"
withString:@""]; withString:@""];
} }
......
...@@ -26,6 +26,12 @@ ...@@ -26,6 +26,12 @@
// Execute all queued events // Execute all queued events
- (void) deviceready:(CDVInvokedUrlCommand*)command; - (void) deviceready:(CDVInvokedUrlCommand*)command;
// Inform if the app has the permission to show notifications
- (void) hasPermission:(CDVInvokedUrlCommand*)command;
// Register permission to show notifications
- (void) registerPermission:(CDVInvokedUrlCommand*)command;
// Schedule a new notification // Schedule a new notification
- (void) add:(CDVInvokedUrlCommand*)command; - (void) add:(CDVInvokedUrlCommand*)command;
// Update a notification // Update a notification
...@@ -34,21 +40,26 @@ ...@@ -34,21 +40,26 @@
- (void) cancel:(CDVInvokedUrlCommand*)command; - (void) cancel:(CDVInvokedUrlCommand*)command;
// Cancel all currently scheduled notifications // Cancel all currently scheduled notifications
- (void) cancelAll:(CDVInvokedUrlCommand*)command; - (void) cancelAll:(CDVInvokedUrlCommand*)command;
// Check if a notification with an ID is scheduled
// If a notification with an ID exists
- (void) exist:(CDVInvokedUrlCommand*)command;
// If a notification with an ID was scheduled
- (void) isScheduled:(CDVInvokedUrlCommand*)command; - (void) isScheduled:(CDVInvokedUrlCommand*)command;
// Check if a notification with an ID was triggered // If a notification with an ID was triggered
- (void) isTriggered:(CDVInvokedUrlCommand*)command; - (void) isTriggered:(CDVInvokedUrlCommand*)command;
// List all ids from all local notifications
- (void) getAllIds:(CDVInvokedUrlCommand*)command;
// List all ids from all pending notifications // List all ids from all pending notifications
- (void) getScheduledIds:(CDVInvokedUrlCommand*)command; - (void) getScheduledIds:(CDVInvokedUrlCommand*)command;
// List all ids from all triggered notifications // List all ids from all triggered notifications
- (void) getTriggeredIds:(CDVInvokedUrlCommand*)command; - (void) getTriggeredIds:(CDVInvokedUrlCommand*)command;
// List all properties for given scheduled notifications
// Property list for given local notifications
- (void) getAll:(CDVInvokedUrlCommand*)command;
// Property list for given scheduled notifications
- (void) getScheduled:(CDVInvokedUrlCommand*)command; - (void) getScheduled:(CDVInvokedUrlCommand*)command;
// List all properties for given triggered notifications // Property list for given triggered notifications
- (void) getTriggered:(CDVInvokedUrlCommand*)command; - (void) getTriggered:(CDVInvokedUrlCommand*)command;
// Inform if the app has the permission to show notifications
- (void) hasPermission:(CDVInvokedUrlCommand*)command;
// Register permission to show notifications
- (void) registerPermission:(CDVInvokedUrlCommand*)command;
@end @end
...@@ -162,6 +162,34 @@ ...@@ -162,6 +162,34 @@
} }
/** /**
* If a notification by ID exists.
*
* @param id
* The ID of the notification
*/
- (void) exist:(CDVInvokedUrlCommand *)command
{
[self.commandDelegate runInBackground:^{
NSString* id = [[command arguments]
objectAtIndex:0];
CDVPluginResult* result;
UILocalNotification* notification;
notification = [[UIApplication sharedApplication]
localNotificationWithId:id];
bool exists = notification != NULL;
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsBool:exists];
[self.commandDelegate sendPluginResult:result
callbackId:command.callbackId];
}];
}
/**
* If a notification by ID is scheduled. * If a notification by ID is scheduled.
* *
* @param id * @param id
...@@ -218,6 +246,26 @@ ...@@ -218,6 +246,26 @@
} }
/** /**
* List all ids from all local notifications.
*/
- (void) getAllIds:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
CDVPluginResult* result;
NSArray* notIds;
notIds = [[UIApplication sharedApplication]
localNotificationIds];
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsArray:notIds];
[self.commandDelegate sendPluginResult:result
callbackId:command.callbackId];
}];
}
/**
* List all ids from all pending notifications. * List all ids from all pending notifications.
*/ */
- (void) getScheduledIds:(CDVInvokedUrlCommand*)command - (void) getScheduledIds:(CDVInvokedUrlCommand*)command
...@@ -258,7 +306,36 @@ ...@@ -258,7 +306,36 @@
} }
/** /**
* List all properties for given scheduled notifications. * Property list for given local notifications.
*
* @param ids
* The IDs of the notifications
*/
- (void) getAll:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
NSArray* ids = command.arguments;
NSArray* notifications;
CDVPluginResult* result;
if (ids.count == 0) {
notifications = [[UIApplication sharedApplication]
localNotificationOptions];
} else {
notifications = [[UIApplication sharedApplication]
localNotificationOptions:ids];
}
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsArray:notifications];
[self.commandDelegate sendPluginResult:result
callbackId:command.callbackId];
}];
}
/**
* Property list for given scheduled notifications.
* *
* @param ids * @param ids
* The IDs of the notifications * The IDs of the notifications
...@@ -287,7 +364,7 @@ ...@@ -287,7 +364,7 @@
} }
/** /**
* List all properties for given triggered notifications. * Property list for given triggered notifications.
* *
* @param ids * @param ids
* The IDs of the notifications * The IDs of the notifications
...@@ -613,7 +690,7 @@ ...@@ -613,7 +690,7 @@
} }
js = [NSString stringWithFormat: js = [NSString stringWithFormat:
@"setTimeout('plugin.notification.local.on%@(%@)',0)", @"setTimeout('cordova.plugins.notification.local.on%@(%@)',0)",
event, params]; event, params];
if (deviceready) { if (deviceready) {
......
...@@ -21,7 +21,11 @@ ...@@ -21,7 +21,11 @@
@interface UIApplication (APPLocalNotification) @interface UIApplication (APPLocalNotification)
@property (readonly, getter=localNotifications) NSArray* localNotifications;
@property (readonly, getter=scheduledLocalNotifications2) NSArray* triggeredLocalNotifications2;
@property (readonly, getter=triggeredLocalNotifications) NSArray* triggeredLocalNotifications; @property (readonly, getter=triggeredLocalNotifications) NSArray* triggeredLocalNotifications;
@property (readonly, getter=localNotificationIds) NSArray* localNotificationIds;
@property (readonly, getter=triggeredLocalNotificationIds) NSArray* triggeredLocalNotificationIds; @property (readonly, getter=triggeredLocalNotificationIds) NSArray* triggeredLocalNotificationIds;
@property (readonly, getter=scheduledLocalNotificationIds) NSArray* scheduledLocalNotificationIds; @property (readonly, getter=scheduledLocalNotificationIds) NSArray* scheduledLocalNotificationIds;
...@@ -29,17 +33,26 @@ ...@@ -29,17 +33,26 @@
- (BOOL) hasPermissionToScheduleLocalNotifications; - (BOOL) hasPermissionToScheduleLocalNotifications;
// Ask for permission to schedule local notifications // Ask for permission to schedule local notifications
- (void) registerPermissionToScheduleLocalNotifications; - (void) registerPermissionToScheduleLocalNotifications;
// Get the scheduled local notification by ID
// Get local notification by ID
- (UILocalNotification*) localNotificationWithId:(NSString*)id;
// Get scheduled local notification by ID
- (UILocalNotification*) scheduledLocalNotificationWithId:(NSString*)id; - (UILocalNotification*) scheduledLocalNotificationWithId:(NSString*)id;
// Get the triggered local notification by ID // Get triggered local notification by ID
- (UILocalNotification*) triggeredLocalNotificationWithId:(NSString*)id; - (UILocalNotification*) triggeredLocalNotificationWithId:(NSString*)id;
// List of properties from all scheduled notifications
// Property list from all local notifications
- (NSArray*) localNotificationOptions;
// Property list from all scheduled notifications
- (NSArray*) scheduledLocalNotificationOptions; - (NSArray*) scheduledLocalNotificationOptions;
// List of properties from given scheduled notifications // Property list from all triggered notifications
- (NSArray*) scheduledLocalNotificationOptions:(NSArray*)ids;
// List of properties from all triggered notifications
- (NSArray*) triggeredLocalNotificationOptions; - (NSArray*) triggeredLocalNotificationOptions;
// List of properties from given triggered notifications
// Property list from given local notifications
- (NSArray*) localNotificationOptions:(NSArray*)ids;
// Property list from given scheduled notifications
- (NSArray*) scheduledLocalNotificationOptions:(NSArray*)ids;
// Property list from given triggered notifications
- (NSArray*) triggeredLocalNotificationOptions:(NSArray*)ids; - (NSArray*) triggeredLocalNotificationOptions:(NSArray*)ids;
@end @end
...@@ -72,18 +72,55 @@ ...@@ -72,18 +72,55 @@
#pragma mark LocalNotifications #pragma mark LocalNotifications
/** /**
* List of all local notifications which have been added
* but not yet removed from the notification center.
*/
- (NSArray*) localNotifications
{
NSArray* scheduledNotifications = self.scheduledLocalNotifications;
NSMutableArray* notifications = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in scheduledNotifications)
{
if (notification) {
[notifications addObject:notification];
}
}
return notifications;
}
/**
* List of all local notifications which have been scheduled
* and not yet removed from the notification center.
*/
- (NSArray*) scheduledLocalNotifications2
{
NSArray* scheduledNotifications = self.scheduledLocalNotifications;
NSMutableArray* notifications = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in scheduledNotifications)
{
if (notification && [notification wasScheduled]) {
[notifications addObject:notification];
}
}
return notifications;
}
/**
* List of all triggered local notifications which have been scheduled * List of all triggered local notifications which have been scheduled
* and not yet removed the notification center. * and not yet removed the notification center.
*/ */
- (NSArray*) triggeredLocalNotifications - (NSArray*) triggeredLocalNotifications
{ {
NSArray* scheduledNotifications = self.scheduledLocalNotifications; NSArray* notifications = self.localNotifications;
NSMutableArray* triggeredNotifications = [[NSMutableArray alloc] init]; NSMutableArray* triggeredNotifications = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in scheduledNotifications) for (UILocalNotification* notification in notifications)
{ {
if (notification && [notification wasTriggered]) if ([notification wasTriggered]) {
{
[triggeredNotifications addObject:notification]; [triggeredNotifications addObject:notification];
} }
} }
...@@ -93,7 +130,24 @@ ...@@ -93,7 +130,24 @@
/** /**
* List of all triggered local notifications IDs which have been scheduled * List of all triggered local notifications IDs which have been scheduled
* and not yet removed the notification center. * and not yet removed from the notification center.
*/
- (NSArray*) localNotificationIds
{
NSArray* notifications = self.localNotifications;
NSMutableArray* ids = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in notifications)
{
[ids addObject:notification.options.id];
}
return ids;
}
/**
* List of all added local notifications IDs which have been scheduled
* and not yet removed from the notification center.
*/ */
- (NSArray*) triggeredLocalNotificationIds - (NSArray*) triggeredLocalNotificationIds
{ {
...@@ -113,32 +167,50 @@ ...@@ -113,32 +167,50 @@
*/ */
- (NSArray*) scheduledLocalNotificationIds - (NSArray*) scheduledLocalNotificationIds
{ {
NSArray* notifications = self.scheduledLocalNotifications; NSArray* notifications = self.scheduledLocalNotifications2;
NSMutableArray* ids = [[NSMutableArray alloc] init]; NSMutableArray* ids = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in notifications) for (UILocalNotification* notification in notifications)
{ {
if (notification) { [ids addObject:notification.options.id];
[ids addObject:notification.options.id];
}
} }
return ids; return ids;
} }
/** /**
* Get the scheduled local notification by ID. * Get local notification by ID.
*
* @param id
* Notification ID
*/
- (UILocalNotification*) localNotificationWithId:(NSString*)id
{
NSArray* notifications = self.localNotifications;
for (UILocalNotification* notification in notifications)
{
if ([notification.options.id isEqualToString:id]) {
return notification;
}
}
return NULL;
}
/**
* Get scheduled local notification by ID.
* *
* @param id * @param id
* Notification ID * Notification ID
*/ */
- (UILocalNotification*) scheduledLocalNotificationWithId:(NSString*)id - (UILocalNotification*) scheduledLocalNotificationWithId:(NSString*)id
{ {
NSArray* notifications = self.scheduledLocalNotifications; NSArray* notifications = self.scheduledLocalNotifications2;
for (UILocalNotification* notification in notifications) for (UILocalNotification* notification in notifications)
{ {
if (notification && [notification.options.id isEqualToString:id]) { if ([notification.options.id isEqualToString:id]) {
return notification; return notification;
} }
} }
...@@ -147,14 +219,14 @@ ...@@ -147,14 +219,14 @@
} }
/** /**
* Get the triggered local notification by ID. * Get triggered local notification by ID.
* *
* @param id * @param id
* Notification ID * Notification ID
*/ */
- (UILocalNotification*) triggeredLocalNotificationWithId:(NSString*)id - (UILocalNotification*) triggeredLocalNotificationWithId:(NSString*)id
{ {
UILocalNotification* notification = [self scheduledLocalNotificationWithId:id]; UILocalNotification* notification = [self localNotificationWithId:id];
if (notification && [notification wasTriggered]) { if (notification && [notification wasTriggered]) {
return notification; return notification;
...@@ -164,37 +236,67 @@ ...@@ -164,37 +236,67 @@
} }
/** /**
* List of properties from all notifications.
*/
- (NSArray*) localNotificationOptions
{
NSArray* notifications = self.localNotifications;
NSMutableArray* options = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in notifications)
{
[options addObject:notification.userInfo];
}
return options;
}
/**
* List of properties from all scheduled notifications. * List of properties from all scheduled notifications.
*/ */
- (NSArray*) scheduledLocalNotificationOptions - (NSArray*) scheduledLocalNotificationOptions
{ {
NSArray* notifications = self.scheduledLocalNotifications; NSArray* notifications = [self scheduledLocalNotifications2];
NSMutableArray* options = [[NSMutableArray alloc] init]; NSMutableArray* options = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in notifications) for (UILocalNotification* notification in notifications)
{ {
if (notification) { [options addObject:notification.userInfo];
[options addObject:notification.userInfo];
}
} }
return options; return options;
} }
/** /**
* List of properties from given scheduled notifications. * List of properties from all triggered notifications.
*/
- (NSArray*) triggeredLocalNotificationOptions
{
NSArray* notifications = self.triggeredLocalNotifications;
NSMutableArray* options = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in notifications)
{
[options addObject:notification.userInfo];
}
return options;
}
/**
* List of properties from given local notifications.
* *
* @param ids * @param ids
* Notification IDs * Notification IDs
*/ */
- (NSArray*) scheduledLocalNotificationOptions:(NSArray*)ids - (NSArray*) localNotificationOptions:(NSArray*)ids
{ {
UILocalNotification* notification; UILocalNotification* notification;
NSMutableArray* options = [[NSMutableArray alloc] init]; NSMutableArray* options = [[NSMutableArray alloc] init];
for (NSString* id in ids) for (NSString* id in ids)
{ {
notification = [self scheduledLocalNotificationWithId:id]; notification = [self localNotificationWithId:id];
if (notification) { if (notification) {
[options addObject:notification.userInfo]; [options addObject:notification.userInfo];
...@@ -205,16 +307,23 @@ ...@@ -205,16 +307,23 @@
} }
/** /**
* List of properties from all triggered notifications. * List of properties from given scheduled notifications.
*
* @param ids
* Notification IDs
*/ */
- (NSArray*) triggeredLocalNotificationOptions - (NSArray*) scheduledLocalNotificationOptions:(NSArray*)ids
{ {
NSArray* notifications = self.triggeredLocalNotifications; UILocalNotification* notification;
NSMutableArray* options = [[NSMutableArray alloc] init]; NSMutableArray* options = [[NSMutableArray alloc] init];
for (UILocalNotification* notification in notifications) for (NSString* id in ids)
{ {
[options addObject:notification.userInfo]; notification = [self scheduledLocalNotificationWithId:id];
if (notification) {
[options addObject:notification.userInfo];
}
} }
return options; return options;
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
- (double) timeIntervalSinceFireDate; - (double) timeIntervalSinceFireDate;
// If the fire date was in the past // If the fire date was in the past
- (BOOL) wasInThePast; - (BOOL) wasInThePast;
// If the notification was already scheduled
- (BOOL) wasScheduled;
// If the notification was already triggered // If the notification was already triggered
- (BOOL) wasTriggered; - (BOOL) wasTriggered;
// If the notification was updated // If the notification was updated
......
...@@ -143,6 +143,32 @@ static char optionsKey; ...@@ -143,6 +143,32 @@ static char optionsKey;
} }
/** /**
* Encode the user info dict to JSON.
*/
- (NSString*) encodeToJSON
{
NSString* json;
NSData* data;
NSMutableDictionary* obj = [self.userInfo mutableCopy];
[obj removeObjectForKey:@"json"];
[obj removeObjectForKey:@"updatedAt"];
data = [NSJSONSerialization dataWithJSONObject:obj
options:NSJSONWritingPrettyPrinted
error:Nil];
json = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
return [json stringByReplacingOccurrencesOfString:@"\n"
withString:@""];
}
#pragma mark -
#pragma mark State
/**
* If the fire date was in the past. * If the fire date was in the past.
*/ */
- (BOOL) wasInThePast - (BOOL) wasInThePast
...@@ -150,6 +176,12 @@ static char optionsKey; ...@@ -150,6 +176,12 @@ static char optionsKey;
return [self timeIntervalSinceFireDate] > 0; return [self timeIntervalSinceFireDate] > 0;
} }
// If the notification was already scheduled
- (BOOL) wasScheduled
{
return [self isRepeating] || ![self wasInThePast];
}
/** /**
* If the notification was already triggered. * If the notification was already triggered.
*/ */
...@@ -158,9 +190,9 @@ static char optionsKey; ...@@ -158,9 +190,9 @@ static char optionsKey;
NSDate* now = [NSDate date]; NSDate* now = [NSDate date];
NSDate* fireDate = self.fireDate; NSDate* fireDate = self.fireDate;
bool isLaterThanOrEqualTo = !([now compare:fireDate] == NSOrderedAscending); bool isLaterThanFireDate = !([now compare:fireDate] == NSOrderedAscending);
return isLaterThanOrEqualTo; return isLaterThanFireDate;
} }
/** /**
...@@ -187,27 +219,4 @@ static char optionsKey; ...@@ -187,27 +219,4 @@ static char optionsKey;
return [self.options isRepeating]; return [self.options isRepeating];
} }
/**
* Encode the user info dict to JSON.
*/
- (NSString*) encodeToJSON
{
NSString* json;
NSData* data;
NSMutableDictionary* obj = [self.userInfo mutableCopy];
[obj removeObjectForKey:@"json"];
[obj removeObjectForKey:@"updatedAt"];
data = [NSJSONSerialization dataWithJSONObject:obj
options:NSJSONWritingPrettyPrinted
error:Nil];
json = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
return [json stringByReplacingOccurrencesOfString:@"\n"
withString:@""];
}
@end @end
...@@ -67,7 +67,8 @@ exports._defaults = { ...@@ -67,7 +67,8 @@ exports._defaults = {
badge: -1, badge: -1,
id: '0', id: '0',
json: '', json: '',
repeat: '' repeat: '',
date: undefined
}; };
...@@ -208,6 +209,29 @@ exports.cancelAll = function (callback, scope) { ...@@ -208,6 +209,29 @@ exports.cancelAll = function (callback, scope) {
}; };
/** /**
* Check if a notification with an ID exists.
*
* @param {String} id
* The ID of the notification
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports.exist = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('exist', notId, callback, scope);
};
/**
* Alias for `exist`.
*/
exports.exists = function () {
this.exist.apply(this, arguments);
};
/**
* Check if a notification with an ID is scheduled. * Check if a notification with an ID is scheduled.
* *
* @param {String} id * @param {String} id
...@@ -240,7 +264,26 @@ exports.isTriggered = function (id, callback, scope) { ...@@ -240,7 +264,26 @@ exports.isTriggered = function (id, callback, scope) {
}; };
/** /**
* List all currently pending notifications. * List all local notification IDs.
*
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports.getAllIds = function (callback, scope) {
this.exec('getAllIds', null, callback, scope);
};
/**
* Alias for `getAllIds`.
*/
exports.getIds = function () {
this.getAllIds.apply(this, arguments);
};
/**
* List all scheduled notification IDs.
* *
* @param {Function} callback * @param {Function} callback
* A callback function to be called with the list * A callback function to be called with the list
...@@ -252,7 +295,7 @@ exports.getScheduledIds = function (callback, scope) { ...@@ -252,7 +295,7 @@ exports.getScheduledIds = function (callback, scope) {
}; };
/** /**
* List all triggered notifications. * List all triggered notification IDs.
* *
* @param {Function} callback * @param {Function} callback
* A callback function to be called with the list * A callback function to be called with the list
...@@ -264,7 +307,50 @@ exports.getTriggeredIds = function (callback, scope) { ...@@ -264,7 +307,50 @@ exports.getTriggeredIds = function (callback, scope) {
}; };
/** /**
* List all properties for given scheduled notifications. * Property list for given local notifications.
* If called without IDs, all notification will be returned.
*
* @param {Number[]?} ids
* Set of notification IDs
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports.get = function () {
var args = Array.apply(null, arguments);
if (typeof args[0] == 'function') {
args.unshift([]);
}
var ids = args[0],
callback = args[1],
scope = args[2];
if (!Array.isArray(ids)) {
ids = [ids];
}
ids = this.convertIds(ids);
this.exec('getAll', ids, callback, scope);
};
/**
* Property list for all local notifications.
*
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports.getAll = function (callback, scope) {
this.exec('getAll', null, callback, scope);
};
/**
* Property list for given scheduled notifications.
* If called without IDs, all notification will be returned. * If called without IDs, all notification will be returned.
* *
* @param {Number[]?} ids * @param {Number[]?} ids
...@@ -307,7 +393,7 @@ exports.getAllScheduled = function (callback, scope) { ...@@ -307,7 +393,7 @@ exports.getAllScheduled = function (callback, scope) {
}; };
/** /**
* List all properties for given triggered notifications. * Property list for given triggered notifications.
* If called without IDs, all notification will be returned. * If called without IDs, all notification will be returned.
* *
* @param {Number[]?} ids * @param {Number[]?} ids
...@@ -634,7 +720,9 @@ exports.convertIds = function (ids) { ...@@ -634,7 +720,9 @@ exports.convertIds = function (ids) {
exports.getValueFor = function (options) { exports.getValueFor = function (options) {
var keys = Array.apply(null, arguments).slice(1); var keys = Array.apply(null, arguments).slice(1);
for (var key in keys) { for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (options.hasOwnProperty(key)) { if (options.hasOwnProperty(key)) {
return options[key]; return options[key];
} }
......
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