Commit fa410a84 by Sebastián Katzer

Update project

parent d069f808
...@@ -109,26 +109,6 @@ ...@@ -109,26 +109,6 @@
</navigator> </navigator>
<panes> <panes>
<pane id="PackagesPane" /> <pane id="PackagesPane" />
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="cordova-example-local-notifications" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="cordova-example-local-notifications" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="android" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="AndroidView"> <pane id="AndroidView">
<subPane> <subPane>
<PATH> <PATH>
...@@ -172,6 +152,26 @@ ...@@ -172,6 +152,26 @@
</subPane> </subPane>
</pane> </pane>
<pane id="Scope" /> <pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="cordova-example-local-notifications" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="cordova-example-local-notifications" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="android" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
...@@ -189,7 +189,7 @@ ...@@ -189,7 +189,7 @@
<property name="android.project.structure.proportion" value="0.15" /> <property name="android.project.structure.proportion" value="0.15" />
<property name="recentsLimit" value="5" /> <property name="recentsLimit" value="5" />
<property name="restartRequiresConfirmation" value="true" /> <property name="restartRequiresConfirmation" value="true" />
<property name="ANDROID_EXTENDED_DEVICE_CHOOSER_SERIALS" value="emulator-5554" /> <property name="ANDROID_EXTENDED_DEVICE_CHOOSER_SERIALS" value="" />
<property name="ANDROID_EXTENDED_DEVICE_CHOOSER_AVD" value="Nexus_5_API_21" /> <property name="ANDROID_EXTENDED_DEVICE_CHOOSER_AVD" value="Nexus_5_API_21" />
<property name="FullScreen" value="false" /> <property name="FullScreen" value="false" />
</component> </component>
...@@ -323,13 +323,12 @@ ...@@ -323,13 +323,12 @@
</option> </option>
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="0" y="23" width="1440" height="809" extended-state="6" /> <frame x="0" y="23" width="1440" height="809" extended-state="0" />
<editor active="false" /> <editor active="false" />
<layout> <layout>
<window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3997114" sideWeight="0.46280402" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3997114" sideWeight="0.46280402" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32900432" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32900432" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" /> <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
...@@ -337,18 +336,19 @@ ...@@ -337,18 +336,19 @@
<window_info id="Build Variants" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" /> <window_info id="Build Variants" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Gradle Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32900432" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Gradle Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32900432" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32756132" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" /> <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32756132" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Android" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32756132" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Android" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32756132" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.2532189" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.2532189" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.21888413" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.22460657" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32756132" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32756132" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Memory Monitor" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3997114" sideWeight="0.53648067" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Memory Monitor" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3997114" sideWeight="0.53648067" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32756132" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32756132" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
</layout> </layout>
......
...@@ -10,16 +10,16 @@ ...@@ -10,16 +10,16 @@
</intent-filter> </intent-filter>
</activity> </activity>
<service android:name="de.appplant.cordova.plugin.background.ForegroundService" /> <service android:name="de.appplant.cordova.plugin.background.ForegroundService" />
<receiver android:exported="false" android:name="de.appplant.cordova.plugin.localnotification.TriggerReceiver" />
<receiver android:exported="false" android:name="de.appplant.cordova.plugin.localnotification.ClearReceiver" />
<activity android:launchMode="singleInstance" android:name="de.appplant.cordova.plugin.localnotification.ClickActivity" android:theme="@android:style/Theme.NoDisplay" />
<receiver android:exported="false" android:name="de.appplant.cordova.plugin.notification.TriggerReceiver" />
<receiver android:exported="false" android:name="de.appplant.cordova.plugin.notification.ClearReceiver" />
<receiver android:name="de.appplant.cordova.plugin.localnotification.RestoreReceiver"> <receiver android:name="de.appplant.cordova.plugin.localnotification.RestoreReceiver">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver android:exported="false" android:name="de.appplant.cordova.plugin.localnotification.TriggerReceiver" />
<receiver android:exported="false" android:name="de.appplant.cordova.plugin.localnotification.ClearReceiver" />
<activity android:launchMode="singleInstance" android:name="de.appplant.cordova.plugin.localnotification.ClickActivity" android:theme="@android:style/Theme.NoDisplay" />
<receiver android:exported="false" android:name="de.appplant.cordova.plugin.notification.TriggerReceiver" />
<receiver android:exported="false" android:name="de.appplant.cordova.plugin.notification.ClearReceiver" />
<activity android:launchMode="singleInstance" android:name="de.appplant.cordova.plugin.notification.ClickActivity" android:theme="@android:style/Theme.NoDisplay" /> <activity android:launchMode="singleInstance" android:name="de.appplant.cordova.plugin.notification.ClickActivity" android:theme="@android:style/Theme.NoDisplay" />
</application> </application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" /> <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />
......
...@@ -169,7 +169,7 @@ ...@@ -169,7 +169,7 @@
<script type="text/javascript"> <script type="text/javascript">
schedule = function () { schedule = function () {
cordova.plugins.notification.local.schedule({ cordova.plugins.notification.local.schedule({
id: 1, // id: 1,
text: 'Test Message 1', text: 'Test Message 1',
icon: 'http://www.optimizeordie.de/wp-content/plugins/social-media-widget/images/default/64/googleplus.png', icon: 'http://www.optimizeordie.de/wp-content/plugins/social-media-widget/images/default/64/googleplus.png',
sound: null, sound: null,
......
...@@ -30,7 +30,7 @@ var exec = require('cordova/exec'), ...@@ -30,7 +30,7 @@ var exec = require('cordova/exec'),
*************/ *************/
/** /**
* Returns the default settings * Returns the default settings.
* *
* @return {Object} * @return {Object}
*/ */
...@@ -39,7 +39,7 @@ exports.getDefaults = function () { ...@@ -39,7 +39,7 @@ exports.getDefaults = function () {
}; };
/** /**
* Overwrite default settings * Overwrite default settings.
* *
* @param {Object} defaults * @param {Object} defaults
*/ */
...@@ -423,17 +423,25 @@ exports.registerPermission = function (callback, scope) { ...@@ -423,17 +423,25 @@ exports.registerPermission = function (callback, scope) {
exec(fn, null, 'LocalNotification', 'registerPermission', []); exec(fn, null, 'LocalNotification', 'registerPermission', []);
}; };
/****************
* DEPRECATIONS *
****************/
/** /**
* @deprecated * Schedule a new local notification.
* */
* Register permission to show notifications if not already granted. exports.add = function () {
* console.warn('Depreated: Please use `notification.local.schedule` instead.');
* @param {Function} callback
* The function to be exec as the callback exports.schedule.apply(this, arguments);
* @param {Object?} scope };
* The callback function's scope
/**
* Register permission to show notifications
* if not already granted.
*/ */
exports.promptForPermission = function (callback, scope) { exports.promptForPermission = function () {
console.warn('Depreated: Please use `notification.local.registerPermission` instead.'); console.warn('Depreated: Please use `notification.local.registerPermission` instead.');
exports.registerPermission.apply(this, arguments); exports.registerPermission.apply(this, arguments);
...@@ -500,7 +508,7 @@ exports._defaults = { ...@@ -500,7 +508,7 @@ exports._defaults = {
title: '', title: '',
sound: 'res://platform_default', sound: 'res://platform_default',
badge: 0, badge: 0,
id: 0, id: "0",
data: undefined, data: undefined,
every: undefined, every: undefined,
at: undefined at: undefined
......
...@@ -180,7 +180,10 @@ public class LocalNotification extends CordovaPlugin { ...@@ -180,7 +180,10 @@ public class LocalNotification extends CordovaPlugin {
for (int i = 0; i < notifications.length(); i++) { for (int i = 0; i < notifications.length(); i++) {
JSONObject options = notifications.optJSONObject(i); JSONObject options = notifications.optJSONObject(i);
getNotificationMgr().schedule(options, TriggerReceiver.class); Notification notification =
getNotificationMgr().schedule(options, TriggerReceiver.class);
fireEvent("schedule", notification);
} }
} }
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#import "UIApplication+APPLocalNotification.h" #import "UIApplication+APPLocalNotification.h"
#import "UILocalNotification+APPLocalNotification.h" #import "UILocalNotification+APPLocalNotification.h"
#import <Availability.h>
@interface APPLocalNotification () @interface APPLocalNotification ()
// Retrieves the application state // Retrieves the application state
...@@ -411,16 +409,17 @@ ...@@ -411,16 +409,17 @@
*/ */
- (void) registerPermission:(CDVInvokedUrlCommand*)command - (void) registerPermission:(CDVInvokedUrlCommand*)command
{ {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 if ([[UIApplication sharedApplication]
respondsToSelector:@selector(registerUserNotificationSettings:)])
_command = command; {
_command = command;
[self.commandDelegate runInBackground:^{ [self.commandDelegate runInBackground:^{
[self.app registerPermissionToScheduleLocalNotifications]; [self.app registerPermissionToScheduleLocalNotifications];
}]; }];
#else } else {
[self hasPermission:command]; [self hasPermission:command];
#endif }
} }
#pragma mark - #pragma mark -
......
...@@ -159,7 +159,7 @@ NSString* const DEFAULT_SOUND = @"res://platform_default"; ...@@ -159,7 +159,7 @@ NSString* const DEFAULT_SOUND = @"res://platform_default";
else if ([interval isEqualToString:@"minute"]) { else if ([interval isEqualToString:@"minute"]) {
return NSCalendarUnitMinute; return NSCalendarUnitMinute;
} }
else if ([interval isEqualToString:@"houre"]) { else if ([interval isEqualToString:@"hour"]) {
return NSCalendarUnitHour; return NSCalendarUnitHour;
} }
else if ([interval isEqualToString:@"day"]) { else if ([interval isEqualToString:@"day"]) {
......
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
#import "UIApplication+APPLocalNotification.h" #import "UIApplication+APPLocalNotification.h"
#import "UILocalNotification+APPLocalNotification.h" #import "UILocalNotification+APPLocalNotification.h"
#import <Availability.h>
@implementation UIApplication (APPLocalNotification) @implementation UIApplication (APPLocalNotification)
#pragma mark - #pragma mark -
...@@ -36,19 +34,21 @@ ...@@ -36,19 +34,21 @@
*/ */
- (BOOL) hasPermissionToScheduleLocalNotifications - (BOOL) hasPermissionToScheduleLocalNotifications
{ {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 if ([[UIApplication sharedApplication]
UIUserNotificationType types; respondsToSelector:@selector(registerUserNotificationSettings:)])
UIUserNotificationSettings *settings; {
UIUserNotificationType types;
UIUserNotificationSettings *settings;
settings = [[UIApplication sharedApplication] settings = [[UIApplication sharedApplication]
currentUserNotificationSettings]; currentUserNotificationSettings];
types = UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound; types = UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound;
return (settings.types & types); return (settings.types & types);
#else } else {
return YES; return YES;
#endif }
} }
/** /**
...@@ -56,18 +56,20 @@ ...@@ -56,18 +56,20 @@
*/ */
- (void) registerPermissionToScheduleLocalNotifications - (void) registerPermissionToScheduleLocalNotifications
{ {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 if ([[UIApplication sharedApplication]
UIUserNotificationType types; respondsToSelector:@selector(registerUserNotificationSettings:)])
UIUserNotificationSettings *settings; {
UIUserNotificationType types;
UIUserNotificationSettings *settings;
types = UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound; types = UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound;
settings = [UIUserNotificationSettings settingsForTypes:types settings = [UIUserNotificationSettings settingsForTypes:types
categories:nil]; categories:nil];
[[UIApplication sharedApplication] [[UIApplication sharedApplication]
registerUserNotificationSettings:settings]; registerUserNotificationSettings:settings];
#endif }
} }
#pragma mark - #pragma mark -
......
...@@ -166,7 +166,6 @@ NSInteger const APPLocalNotificationTypeTriggered = 2; ...@@ -166,7 +166,6 @@ NSInteger const APPLocalNotificationTypeTriggered = 2;
NSData* data; NSData* data;
NSMutableDictionary* obj = [self.userInfo mutableCopy]; NSMutableDictionary* obj = [self.userInfo mutableCopy];
[obj removeObjectForKey:@"json"];
[obj removeObjectForKey:@"updatedAt"]; [obj removeObjectForKey:@"updatedAt"];
data = [NSJSONSerialization dataWithJSONObject:obj data = [NSJSONSerialization dataWithJSONObject:obj
......
...@@ -289,48 +289,48 @@ ...@@ -289,48 +289,48 @@
<!-- IDs --> <!-- IDs -->
<script type="text/javascript"> <script type="text/javascript">
var callback = function (ids) { var fn = function (ids) {
showToast(ids.length === 0 ? '- none -' : ids.join(' ,')); showToast(ids.length === 0 ? '- none -' : ids.join(' ,'));
}; };
getIds = function () { getIds = function () {
cordova.plugins.notification.local.getIds(callback); cordova.plugins.notification.local.getIds(fn);
}; };
getScheduledIds = function () { getScheduledIds = function () {
cordova.plugins.notification.local.getScheduledIds(callback); cordova.plugins.notification.local.getScheduledIds(fn);
}; };
getTriggeredIds = function () { getTriggeredIds = function () {
cordova.plugins.notification.local.getTriggeredIds(callback); cordova.plugins.notification.local.getTriggeredIds(fn);
}; };
</script> </script>
<!-- notifications --> <!-- notifications -->
<script type="text/javascript"> <script type="text/javascript">
var callback = function (notifications) { var fn = function (notifications) {
console.log(notifications); console.log(notifications);
showToast(notifications.length === 0 ? '- none -' : notifications.join(' ,')); showToast(notifications.length === 0 ? '- none -' : notifications.join(' ,'));
}; };
get = function () { get = function () {
cordova.plugins.notification.local.get(1, callback); cordova.plugins.notification.local.get(1, fn);
}; };
getMultiple = function () { getMultiple = function () {
cordova.plugins.notification.local.get([1, 2], callback); cordova.plugins.notification.local.get([1, 2], fn);
}; };
getAll = function () { getAll = function () {
cordova.plugins.notification.local.getAll(callback); cordova.plugins.notification.local.getAll(fn);
}; };
getScheduled = function () { getScheduled = function () {
cordova.plugins.notification.local.getScheduled(callback); cordova.plugins.notification.local.getScheduled(fn);
}; };
getTriggered = function () { getTriggered = function () {
cordova.plugins.notification.local.getTriggered(callback); cordova.plugins.notification.local.getTriggered(fn);
}; };
</script> </script>
......
...@@ -30,7 +30,7 @@ var exec = require('cordova/exec'), ...@@ -30,7 +30,7 @@ var exec = require('cordova/exec'),
*************/ *************/
/** /**
* Returns the default settings * Returns the default settings.
* *
* @return {Object} * @return {Object}
*/ */
...@@ -39,7 +39,7 @@ exports.getDefaults = function () { ...@@ -39,7 +39,7 @@ exports.getDefaults = function () {
}; };
/** /**
* Overwrite default settings * Overwrite default settings.
* *
* @param {Object} defaults * @param {Object} defaults
*/ */
...@@ -423,17 +423,25 @@ exports.registerPermission = function (callback, scope) { ...@@ -423,17 +423,25 @@ exports.registerPermission = function (callback, scope) {
exec(fn, null, 'LocalNotification', 'registerPermission', []); exec(fn, null, 'LocalNotification', 'registerPermission', []);
}; };
/****************
* DEPRECATIONS *
****************/
/** /**
* @deprecated * Schedule a new local notification.
* */
* Register permission to show notifications if not already granted. exports.add = function () {
* console.warn('Depreated: Please use `notification.local.schedule` instead.');
* @param {Function} callback
* The function to be exec as the callback exports.schedule.apply(this, arguments);
* @param {Object?} scope };
* The callback function's scope
/**
* Register permission to show notifications
* if not already granted.
*/ */
exports.promptForPermission = function (callback, scope) { exports.promptForPermission = function () {
console.warn('Depreated: Please use `notification.local.registerPermission` instead.'); console.warn('Depreated: Please use `notification.local.registerPermission` instead.');
exports.registerPermission.apply(this, arguments); exports.registerPermission.apply(this, arguments);
...@@ -500,7 +508,7 @@ exports._defaults = { ...@@ -500,7 +508,7 @@ exports._defaults = {
title: '', title: '',
sound: 'res://platform_default', sound: 'res://platform_default',
badge: 0, badge: 0,
id: 0, id: "0",
data: undefined, data: undefined,
every: undefined, every: undefined,
at: undefined at: undefined
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
"count": 1 "count": 1
}, },
{ {
"xml": "<receiver android:name=\"de.appplant.cordova.plugin.notification.RestoreReceiver\"><intent-filter><action android:name=\"android.intent.action.BOOT_COMPLETED\" /></intent-filter></receiver>", "xml": "<receiver android:name=\"de.appplant.cordova.plugin.localnotification.RestoreReceiver\"><intent-filter><action android:name=\"android.intent.action.BOOT_COMPLETED\" /></intent-filter></receiver>",
"count": 1 "count": 1
}, },
{ {
......
...@@ -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 [yyyy] [name of copyright owner] Copyright 2013-2015 appPlant UG, Inc.
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.
......
<p align="right">
<a href="https://github.com/katzer/cordova-plugin-local-notifications/tree/example">EXAMPLE :point_right:</a>
</p>
Cordova Local-Notification Plugin Cordova Local-Notification Plugin
================================== ==================================
...@@ -145,8 +150,7 @@ The method takes a hash as an argument to specify the notification's properties ...@@ -145,8 +150,7 @@ The method takes a hash as an argument to specify the notification's properties
Scheduling a local notification will override an earlier one with the same ID. Scheduling a local notification will override an earlier one with the same ID.
All properties are optional. If no date object is given, the notification pops-up immediately. All properties are optional. If no date object is given, the notification pops-up immediately.
**Note:** On Android the notification id needs to be a string which can be converted to a number. **Note:** The notification ID must be a string which can be converted to a number (that is, `isNaN()` returns false for). If the ID has an invalid format, it will silently be changed to `0` and will override an earlier one with the same ID.
If the ID has an invalid format, it will be ignored, but cancelling the notification will fail.
#### Further information #### Further information
- See the [onadd][onadd] event for registering a listener to be notified when a local notification has been scheduled. - See the [onadd][onadd] event for registering a listener to be notified when a local notification has been scheduled.
......
...@@ -14,12 +14,16 @@ ...@@ -14,12 +14,16 @@
<author>Sebastián Katzer</author> <author>Sebastián Katzer</author>
<!-- cordova -->
<engines> <engines>
<engine name="cordova" version=">=3.0.0" /> <engine name="cordova" version=">=3.0.0" />
</engines> </engines>
<dependency id="org.apache.cordova.device" url="https://github.com/apache/cordova-plugin-device" /> <dependency
id="org.apache.cordova.device"
url="https://github.com/apache/cordova-plugin-device" />
<!-- js -->
<js-module src="www/local-notification.js" name="LocalNotification"> <js-module src="www/local-notification.js" name="LocalNotification">
<clobbers target="cordova.plugins.notification.local" /> <clobbers target="cordova.plugins.notification.local" />
<clobbers target="plugin.notification.local" /> <clobbers target="plugin.notification.local" />
...@@ -81,7 +85,7 @@ ...@@ -81,7 +85,7 @@
android:name="de.appplant.cordova.plugin.notification.ClearReceiver" android:name="de.appplant.cordova.plugin.notification.ClearReceiver"
android:exported="false" /> android:exported="false" />
<receiver android:name="de.appplant.cordova.plugin.notification.RestoreReceiver" > <receiver android:name="de.appplant.cordova.plugin.localnotification.RestoreReceiver" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter> </intent-filter>
......
...@@ -180,7 +180,10 @@ public class LocalNotification extends CordovaPlugin { ...@@ -180,7 +180,10 @@ public class LocalNotification extends CordovaPlugin {
for (int i = 0; i < notifications.length(); i++) { for (int i = 0; i < notifications.length(); i++) {
JSONObject options = notifications.optJSONObject(i); JSONObject options = notifications.optJSONObject(i);
getNotificationMgr().schedule(options, TriggerReceiver.class); Notification notification =
getNotificationMgr().schedule(options, TriggerReceiver.class);
fireEvent("schedule", notification);
} }
} }
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#import "UIApplication+APPLocalNotification.h" #import "UIApplication+APPLocalNotification.h"
#import "UILocalNotification+APPLocalNotification.h" #import "UILocalNotification+APPLocalNotification.h"
#import <Availability.h>
@interface APPLocalNotification () @interface APPLocalNotification ()
// Retrieves the application state // Retrieves the application state
...@@ -411,16 +409,17 @@ ...@@ -411,16 +409,17 @@
*/ */
- (void) registerPermission:(CDVInvokedUrlCommand*)command - (void) registerPermission:(CDVInvokedUrlCommand*)command
{ {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 if ([[UIApplication sharedApplication]
respondsToSelector:@selector(registerUserNotificationSettings:)])
_command = command; {
_command = command;
[self.commandDelegate runInBackground:^{ [self.commandDelegate runInBackground:^{
[self.app registerPermissionToScheduleLocalNotifications]; [self.app registerPermissionToScheduleLocalNotifications];
}]; }];
#else } else {
[self hasPermission:command]; [self hasPermission:command];
#endif }
} }
#pragma mark - #pragma mark -
......
...@@ -159,7 +159,7 @@ NSString* const DEFAULT_SOUND = @"res://platform_default"; ...@@ -159,7 +159,7 @@ NSString* const DEFAULT_SOUND = @"res://platform_default";
else if ([interval isEqualToString:@"minute"]) { else if ([interval isEqualToString:@"minute"]) {
return NSCalendarUnitMinute; return NSCalendarUnitMinute;
} }
else if ([interval isEqualToString:@"houre"]) { else if ([interval isEqualToString:@"hour"]) {
return NSCalendarUnitHour; return NSCalendarUnitHour;
} }
else if ([interval isEqualToString:@"day"]) { else if ([interval isEqualToString:@"day"]) {
......
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
#import "UIApplication+APPLocalNotification.h" #import "UIApplication+APPLocalNotification.h"
#import "UILocalNotification+APPLocalNotification.h" #import "UILocalNotification+APPLocalNotification.h"
#import <Availability.h>
@implementation UIApplication (APPLocalNotification) @implementation UIApplication (APPLocalNotification)
#pragma mark - #pragma mark -
...@@ -36,19 +34,21 @@ ...@@ -36,19 +34,21 @@
*/ */
- (BOOL) hasPermissionToScheduleLocalNotifications - (BOOL) hasPermissionToScheduleLocalNotifications
{ {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 if ([[UIApplication sharedApplication]
UIUserNotificationType types; respondsToSelector:@selector(registerUserNotificationSettings:)])
UIUserNotificationSettings *settings; {
UIUserNotificationType types;
UIUserNotificationSettings *settings;
settings = [[UIApplication sharedApplication] settings = [[UIApplication sharedApplication]
currentUserNotificationSettings]; currentUserNotificationSettings];
types = UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound; types = UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound;
return (settings.types & types); return (settings.types & types);
#else } else {
return YES; return YES;
#endif }
} }
/** /**
...@@ -56,18 +56,20 @@ ...@@ -56,18 +56,20 @@
*/ */
- (void) registerPermissionToScheduleLocalNotifications - (void) registerPermissionToScheduleLocalNotifications
{ {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 if ([[UIApplication sharedApplication]
UIUserNotificationType types; respondsToSelector:@selector(registerUserNotificationSettings:)])
UIUserNotificationSettings *settings; {
UIUserNotificationType types;
UIUserNotificationSettings *settings;
types = UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound; types = UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound;
settings = [UIUserNotificationSettings settingsForTypes:types settings = [UIUserNotificationSettings settingsForTypes:types
categories:nil]; categories:nil];
[[UIApplication sharedApplication] [[UIApplication sharedApplication]
registerUserNotificationSettings:settings]; registerUserNotificationSettings:settings];
#endif }
} }
#pragma mark - #pragma mark -
......
...@@ -166,7 +166,6 @@ NSInteger const APPLocalNotificationTypeTriggered = 2; ...@@ -166,7 +166,6 @@ NSInteger const APPLocalNotificationTypeTriggered = 2;
NSData* data; NSData* data;
NSMutableDictionary* obj = [self.userInfo mutableCopy]; NSMutableDictionary* obj = [self.userInfo mutableCopy];
[obj removeObjectForKey:@"json"];
[obj removeObjectForKey:@"updatedAt"]; [obj removeObjectForKey:@"updatedAt"];
data = [NSJSONSerialization dataWithJSONObject:obj data = [NSJSONSerialization dataWithJSONObject:obj
......
...@@ -30,7 +30,7 @@ var exec = require('cordova/exec'), ...@@ -30,7 +30,7 @@ var exec = require('cordova/exec'),
*************/ *************/
/** /**
* Returns the default settings * Returns the default settings.
* *
* @return {Object} * @return {Object}
*/ */
...@@ -39,7 +39,7 @@ exports.getDefaults = function () { ...@@ -39,7 +39,7 @@ exports.getDefaults = function () {
}; };
/** /**
* Overwrite default settings * Overwrite default settings.
* *
* @param {Object} defaults * @param {Object} defaults
*/ */
...@@ -423,17 +423,25 @@ exports.registerPermission = function (callback, scope) { ...@@ -423,17 +423,25 @@ exports.registerPermission = function (callback, scope) {
exec(fn, null, 'LocalNotification', 'registerPermission', []); exec(fn, null, 'LocalNotification', 'registerPermission', []);
}; };
/****************
* DEPRECATIONS *
****************/
/** /**
* @deprecated * Schedule a new local notification.
* */
* Register permission to show notifications if not already granted. exports.add = function () {
* console.warn('Depreated: Please use `notification.local.schedule` instead.');
* @param {Function} callback
* The function to be exec as the callback exports.schedule.apply(this, arguments);
* @param {Object?} scope };
* The callback function's scope
/**
* Register permission to show notifications
* if not already granted.
*/ */
exports.promptForPermission = function (callback, scope) { exports.promptForPermission = function () {
console.warn('Depreated: Please use `notification.local.registerPermission` instead.'); console.warn('Depreated: Please use `notification.local.registerPermission` instead.');
exports.registerPermission.apply(this, arguments); exports.registerPermission.apply(this, arguments);
...@@ -500,7 +508,7 @@ exports._defaults = { ...@@ -500,7 +508,7 @@ exports._defaults = {
title: '', title: '',
sound: 'res://platform_default', sound: 'res://platform_default',
badge: 0, badge: 0,
id: 0, id: "0",
data: undefined, data: undefined,
every: undefined, every: undefined,
at: undefined at: undefined
......
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