Commit ab7fa803 by Sebastián Katzer

Update project

parent 9b453cc0
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DaemonCodeAnalyzer">
<disable_hints />
</component>
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
......@@ -32,61 +29,9 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="Android API 21 Platform" project-jdk-type="Android SDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="Android API 22 Platform" project-jdk-type="Android SDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="RunManager">
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" value="javadebug" />
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
<method />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
<method />
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<envs />
<patterns />
<method />
</configuration>
<list size="0" />
<configuration name="&lt;template&gt;" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" default="true" selected="false">
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
</configuration>
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host>
<Port>5050</Port>
</configuration>
</component>
<component name="masterDetails">
<states>
<state key="Copyright.UI">
......@@ -126,5 +71,4 @@
</state>
</states>
</component>
</project>
</project>
\ No newline at end of file
......@@ -22,6 +22,6 @@
<activity android:exported="false" android:launchMode="singleInstance" android:name="de.appplant.cordova.plugin.notification.ClickActivity" android:theme="@android:style/Theme.NoDisplay" />
</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
......@@ -172,9 +172,7 @@ exports.cancelAll = function (callback, scope) {
* The scope for the callback function
*/
exports.isPresent = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('isPresent', notId, callback, scope);
this.exec('isPresent', id || 0, callback, scope);
};
/**
......@@ -188,9 +186,7 @@ exports.isPresent = function (id, callback, scope) {
* The scope for the callback function
*/
exports.isScheduled = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('isScheduled', notId, callback, scope);
this.exec('isScheduled', id || 0, callback, scope);
};
/**
......@@ -204,9 +200,7 @@ exports.isScheduled = function (id, callback, scope) {
* The scope for the callback function
*/
exports.isTriggered = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('isTriggered', notId, callback, scope);
this.exec('isTriggered', id || 0, callback, scope);
};
/**
......@@ -275,7 +269,7 @@ exports.get = function () {
scope = args[2];
if (!Array.isArray(ids)) {
this.exec('getSingle', ids.toString(), callback, scope);
this.exec('getSingle', Number(ids), callback, scope);
return;
}
......@@ -323,7 +317,7 @@ exports.getScheduled = function () {
}
if (!Array.isArray(ids)) {
this.exec('getSingleScheduled', ids.toString(), callback, scope);
this.exec('getSingleScheduled', Number(ids), callback, scope);
return;
}
......@@ -371,7 +365,7 @@ exports.getTriggered = function () {
}
if (!Array.isArray(ids)) {
this.exec('getSingleTriggered', ids.toString(), callback, scope);
this.exec('getSingleTriggered', Number(ids), callback, scope);
return;
}
......
......@@ -35,7 +35,7 @@ exports._defaults = {
title: '',
sound: 'res://platform_default',
badge: 0,
id: "0",
id: 0,
data: undefined,
every: undefined,
at: undefined
......@@ -87,7 +87,9 @@ exports.mergeWithDefaults = function (options) {
options.text = this.getValueFor(options, 'text', 'message');
options.data = this.getValueFor(options, 'data', 'json');
options.autoClear = this.getValueFor(options, 'autoClear', 'autoCancel');
if (defaults.hasOwnProperty('autoClear')) {
options.autoClear = this.getValueFor(options, 'autoClear', 'autoCancel');
}
if (options.autoClear !== true && options.ongoing) {
options.autoClear = false;
......@@ -131,8 +133,9 @@ exports.convertProperties = function (options) {
if (options.id) {
if (isNaN(options.id)) {
options.id = this.getDefaults().id;
console.warn('Id is not a number: ' + options.id);
} else {
options.id = options.id.toString();
options.id = Number(options.id);
}
}
......@@ -147,13 +150,18 @@ exports.convertProperties = function (options) {
if (options.badge) {
if (isNaN(options.badge)) {
options.badge = this.getDefaults().badge;
console.warn('Badge number is not a number: ' + options.id);
} else {
options.badge = Number(options.badge);
}
}
if (typeof options.at == 'object') {
options.at = Math.round(options.at.getTime()/1000);
if (options.at) {
if (typeof options.at == 'object') {
options.at = options.at.getTime();
}
options.at = Math.round(options.at/1000);
}
if (typeof options.data == 'object') {
......@@ -175,6 +183,7 @@ exports.convertProperties = function (options) {
* The new callback function
*/
exports.createCallbackFn = function (callbackFn, scope) {
if (typeof callbackFn != 'function')
return;
......@@ -184,17 +193,17 @@ exports.createCallbackFn = function (callbackFn, scope) {
};
/**
* Convert the IDs to Strings.
* Convert the IDs to numbers.
*
* @param {String/Number[]} ids
*
* @return Array of Strings
* @return Array of Numbers
*/
exports.convertIds = function (ids) {
var convertedIds = [];
for (var i = 0; i < ids.length; i++) {
convertedIds.push(ids[i].toString());
convertedIds.push(Number(ids[i]));
}
return convertedIds;
......
......@@ -23,7 +23,8 @@
package de.appplant.cordova.plugin.localnotification;
import de.appplant.cordova.plugin.notification.*;
import de.appplant.cordova.plugin.notification.Builder;
import de.appplant.cordova.plugin.notification.Notification;
import de.appplant.cordova.plugin.notification.TriggerReceiver;
/**
......
......@@ -23,8 +23,7 @@
package de.appplant.cordova.plugin.localnotification;
import java.util.ArrayList;
import java.util.List;
import android.os.Build;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
......@@ -35,9 +34,11 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.os.Build;
import java.util.ArrayList;
import java.util.List;
import de.appplant.cordova.plugin.notification.*;
import de.appplant.cordova.plugin.notification.Manager;
import de.appplant.cordova.plugin.notification.Notification;
/**
* This plugin utilizes the Android AlarmManager in combination with local
......@@ -249,7 +250,9 @@ public class LocalNotification extends CordovaPlugin {
Notification notification =
getNotificationMgr().cancel(id);
fireEvent("cancel", notification);
if (notification != null) {
fireEvent("cancel", notification);
}
}
}
......@@ -274,7 +277,9 @@ public class LocalNotification extends CordovaPlugin {
Notification notification =
getNotificationMgr().clear(id);
fireEvent("clear", notification);
if (notification != null) {
fireEvent("clear", notification);
}
}
}
......
......@@ -42,7 +42,9 @@ public class RestoreReceiver extends AbstractRestoreReceiver {
*/
@Override
public void onRestore (Notification notification) {
notification.schedule();
if (notification.isScheduled()) {
notification.schedule();
}
}
/**
......
......@@ -23,7 +23,8 @@
package de.appplant.cordova.plugin.localnotification;
import de.appplant.cordova.plugin.notification.*;
import de.appplant.cordova.plugin.notification.Builder;
import de.appplant.cordova.plugin.notification.Notification;
/**
* The alarm receiver is triggered when a scheduled alarm is fired. This class
......
......@@ -23,16 +23,6 @@
package de.appplant.cordova.plugin.notification;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
......@@ -43,6 +33,16 @@ import android.net.Uri;
import android.os.StrictMode;
import android.util.Log;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
/**
* Util class to map unified asset URIs to native URIs. URIs like file:///
* map to absolute paths while file:// point relatively to the www folder
......@@ -60,7 +60,7 @@ class AssetUtil {
// Ref to the context passed through the constructor to access the
// resources and app directory.
private final Context context;
/**
* Constructor
*
......@@ -102,7 +102,7 @@ class AssetUtil {
/**
* The URI for a path.
*
*
* @param path
* The given path
*/
......@@ -120,15 +120,13 @@ class AssetUtil {
return Uri.EMPTY;
}
/**
* URI for a file.
*
*
* @param path
* Absolute path like file:///...
*
*
* @return
* URI pointing to the given path
*/
......@@ -146,10 +144,10 @@ class AssetUtil {
/**
* URI for an asset.
*
*
* @param path
* Asset path like file://...
*
*
* @return
* URI pointing to the given path
*/
......@@ -191,10 +189,10 @@ class AssetUtil {
/**
* The URI for a resource.
*
*
* @param path
* The given relative path
*
*
* @return
* URI pointing to the given path
*/
......@@ -240,7 +238,7 @@ class AssetUtil {
return Uri.EMPTY;
}
/**
* Uri from remote located content.
*
......@@ -286,11 +284,11 @@ class AssetUtil {
outStream.flush();
outStream.close();
return Uri.fromFile(file);
} catch (MalformedURLException e) {
Log.e("Asset", "Incorrect URL");
Log.e("Asset", "Incorrect URL");
e.printStackTrace();
} catch (FileNotFoundException e) {
Log.e("Asset", "Failed to create new File from HTTP Content");
......@@ -305,7 +303,7 @@ class AssetUtil {
/**
* Copy content from input stream into output stream.
*
*
* @param in
* The input stream
* @param out
......
......@@ -23,8 +23,6 @@
package de.appplant.cordova.plugin.notification;
import java.util.Random;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
......@@ -33,6 +31,8 @@ import android.support.v4.app.NotificationCompat;
import org.json.JSONObject;
import java.util.Random;
/**
* Builder class for local notifications. Build fully configured local
* notification specified by JSON object passed from JS side.
......@@ -158,7 +158,7 @@ public class Builder {
return;
Intent deleteIntent = new Intent(context, clearReceiver)
.setAction(options.getId())
.setAction(options.getIdStr())
.putExtra(Options.EXTRA, options.toString());
PendingIntent dpi = PendingIntent.getBroadcast(
......
......@@ -23,8 +23,6 @@
package de.appplant.cordova.plugin.notification;
import static de.appplant.cordova.plugin.notification.Notification.PREF_KEY;
import android.app.NotificationManager;
import android.content.Context;
import android.content.SharedPreferences;
......@@ -34,12 +32,13 @@ import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static de.appplant.cordova.plugin.notification.Notification.PREF_KEY;
/**
* Central way to access all or single local notifications set by specific
* state like triggered or scheduled. Offers shortcut ways to schedule,
......
......@@ -45,7 +45,7 @@ import java.util.Date;
public class Notification {
// Used to differ notifications by their life cycle state
public static enum Type {
public enum Type {
ALL, SCHEDULED, TRIGGERED
}
......@@ -105,7 +105,7 @@ public class Notification {
* Get notification ID.
*/
public int getId () {
return options.getIdAsInt();
return options.getId();
}
/**
......@@ -162,27 +162,23 @@ public class Notification {
* Schedule the local notification.
*/
public void schedule() {
long triggerTime = getNextTriggerTime();
long triggerTime = options.getTriggerTime();
persist();
// Intent gets called when the Notification gets fired
Intent intent = new Intent(context, receiver)
.setAction(options.getId())
.setAction(options.getIdStr())
.putExtra(Options.EXTRA, options.toString());
PendingIntent pi = PendingIntent.getBroadcast(
context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
getAlarmMgr().set(AlarmManager.RTC_WAKEUP, triggerTime, pi);
}
/**
* Re-schedule the local notification if repeating.
*/
void reschedule () {
if (isRepeating()) {
schedule();
getAlarmMgr().setRepeating(AlarmManager.RTC_WAKEUP,
triggerTime, options.getRepeatInterval(), pi);
} else {
getAlarmMgr().set(AlarmManager.RTC_WAKEUP, triggerTime, pi);
}
}
......@@ -208,13 +204,13 @@ public class Notification {
*/
public void cancel() {
Intent intent = new Intent(context, receiver)
.setAction(options.getId());
.setAction(options.getIdStr());
PendingIntent pi = PendingIntent.
getBroadcast(context, 0, intent, 0);
getAlarmMgr().cancel(pi);
getNotMgr().cancel(options.getIdAsInt());
getNotMgr().cancel(options.getId());
unpersist();
}
......@@ -232,7 +228,7 @@ public class Notification {
*/
@SuppressWarnings("deprecation")
private void showNotification () {
int id = getOptions().getIdAsInt();
int id = getOptions().getId();
if (Build.VERSION.SDK_INT <= 15) {
// Notification for HoneyComb to ICS
......@@ -251,26 +247,11 @@ public class Notification {
}
/**
* Next trigger time.
*/
public long getNextTriggerTime() {
long triggerTime = options.getTriggerTime();
if (!isRepeating() || !isTriggered())
return triggerTime;
long interval = options.getRepeatInterval();
int triggerCount = getTriggerCountSinceSchedule();
return triggerTime + (triggerCount + 1) * interval;
}
/**
* Count of triggers since schedule.
*/
public int getTriggerCountSinceSchedule() {
long now = System.currentTimeMillis();
long initTriggerTime = options.getTriggerTime();
long triggerTime = options.getTriggerTime();
if (!wasInThePast())
return 0;
......@@ -278,7 +259,7 @@ public class Notification {
if (!isRepeating())
return 1;
return (int) ((now - initTriggerTime) / options.getRepeatInterval());
return (int) ((now - triggerTime) / options.getRepeatInterval());
}
/**
......@@ -294,6 +275,7 @@ public class Notification {
e.printStackTrace();
}
json.remove("firstAt");
json.remove("updatedAt");
json.remove("soundUri");
json.remove("iconUri");
......@@ -309,7 +291,7 @@ public class Notification {
private void persist () {
SharedPreferences.Editor editor = getPrefs().edit();
editor.putString(options.getId(), options.toString());
editor.putString(options.getIdStr(), options.toString());
if (Build.VERSION.SDK_INT < 9) {
editor.commit();
......@@ -324,7 +306,7 @@ public class Notification {
private void unpersist () {
SharedPreferences.Editor editor = getPrefs().edit();
editor.remove(options.getId());
editor.remove(options.getIdStr());
if (Build.VERSION.SDK_INT < 9) {
editor.commit();
......
......@@ -23,16 +23,16 @@
package de.appplant.cordova.plugin.notification;
import java.util.Date;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.AlarmManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Date;
/**
* Wrapper around the JSON object passed through JS which contains all
* possible option values. Class provides simple readers and more advanced
......@@ -189,35 +189,34 @@ public class Options {
}
/**
* Trigger date in milliseconds.
* ID for the local notification as a number.
*/
public long getTriggerTime() {
return options.optLong("at", 0) * 1000;
public Integer getId() {
return options.optInt("id", 0);
}
/**
* Trigger date.
* ID for the local notification as a string.
*/
public Date getTriggerDate() {
return new Date(getTriggerTime());
public String getIdStr() {
return getId().toString();
}
/**
* ID for the local notification.
* Trigger date.
*/
public String getId() {
return options.optString("id", "0");
public Date getTriggerDate() {
return new Date(getTriggerTime());
}
/**
* ID for the local notification.
* Trigger date in milliseconds.
*/
public int getIdAsInt() {
try {
return Integer.parseInt(getId());
} catch (Exception ignore) {
return 0;
}
public long getTriggerTime() {
return Math.max(
System.currentTimeMillis(),
options.optLong("at", 0) * 1000
);
}
/**
......
......@@ -42,11 +42,6 @@ public class TriggerReceiver extends AbstractTriggerReceiver {
*/
@Override
public void onTrigger (Notification notification, boolean updated) {
if (notification.isRepeating()) {
notification.reschedule();
}
notification.show();
}
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D2AAC07D0554694100DB518D"
BuildableName = "libCordova.a"
BlueprintName = "CordovaLib"
ReferencedContainer = "container:CordovaLib.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D2AAC07D0554694100DB518D"
BuildableName = "libCordova.a"
BlueprintName = "CordovaLib"
ReferencedContainer = "container:CordovaLib.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D2AAC07D0554694100DB518D"
BuildableName = "libCordova.a"
BlueprintName = "CordovaLib"
ReferencedContainer = "container:CordovaLib.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>CordovaLib.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>D2AAC07D0554694100DB518D</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:NotificationExample.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>A63F5FF5-C059-403D-81B9-E740110FFC25</string>
<key>IDESourceControlProjectName</key>
<string>NotificationExample</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>E6A4395732CC1C6C7441E85472223F9AAF3A67CD</key>
<string>github.com:katzer/cordova-plugin-local-notifications.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>platforms/ios/NotificationExample.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>E6A4395732CC1C6C7441E85472223F9AAF3A67CD</key>
<string>../../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>github.com:katzer/cordova-plugin-local-notifications.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>E6A4395732CC1C6C7441E85472223F9AAF3A67CD</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>E6A4395732CC1C6C7441E85472223F9AAF3A67CD</string>
<key>IDESourceControlWCCName</key>
<string>cordova-example-local-notifications</string>
</dict>
</array>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "NotificationExample.app"
BlueprintName = "NotificationExample"
ReferencedContainer = "container:NotificationExample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "NotificationExample.app"
BlueprintName = "NotificationExample"
ReferencedContainer = "container:NotificationExample.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "NotificationExample.app"
BlueprintName = "NotificationExample"
ReferencedContainer = "container:NotificationExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "NotificationExample.app"
BlueprintName = "NotificationExample"
ReferencedContainer = "container:NotificationExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>NotificationExample.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>1D6058900D05DD3D006BFB54</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
......@@ -61,6 +61,13 @@
// List all ids from all triggered notifications
- (void) getTriggeredIds:(CDVInvokedUrlCommand*)command;
// Propertys for given local notification
- (void) getSingle:(CDVInvokedUrlCommand*)command;
// Propertya for given scheduled notification
- (void) getSingleScheduled:(CDVInvokedUrlCommand*)command;
// Propertys for given triggered notification
- (void) getSingleTriggered:(CDVInvokedUrlCommand*)command;
// Property list for given local notifications
- (void) getAll:(CDVInvokedUrlCommand*)command;
// Property list for given scheduled notifications
......
......@@ -102,7 +102,7 @@
[self.commandDelegate runInBackground:^{
for (NSDictionary* options in notifications) {
NSString* id = [options objectForKey:@"id"];
NSNumber* id = [options objectForKey:@"id"];
UILocalNotification* notification;
notification = [self.app localNotificationWithId:id];
......@@ -133,7 +133,7 @@
- (void) cancel:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
for (NSString* id in command.arguments) {
for (NSNumber* id in command.arguments) {
UILocalNotification* notification;
notification = [self.app localNotificationWithId:id];
......@@ -170,7 +170,7 @@
- (void) clear:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
for (NSString* id in command.arguments) {
for (NSNumber* id in command.arguments) {
UILocalNotification* notification;
notification = [self.app localNotificationWithId:id];
......@@ -241,7 +241,7 @@
type:(APPLocalNotificationType)type;
{
[self.commandDelegate runInBackground:^{
NSString* id = [command argumentAtIndex:0];
NSNumber* id = [command argumentAtIndex:0];
BOOL exist;
CDVPluginResult* result;
......@@ -314,6 +314,28 @@
}
/**
* Propertys for given local notification.
*/
- (void) getSingle:(CDVInvokedUrlCommand*)command
{
[self getOption:command byType:NotifcationTypeAll];
}
/**
* Propertya for given scheduled notification.
*/
- (void) getSingleScheduled:(CDVInvokedUrlCommand*)command
{
[self getOption:command byType:NotifcationTypeScheduled];
}
// Propertys for given triggered notification
- (void) getSingleTriggered:(CDVInvokedUrlCommand*)command
{
[self getOption:command byType:NotifcationTypeTriggered];
}
/**
* Property list for given local notifications.
*
* @param ids
......@@ -347,6 +369,38 @@
}
/**
* Propertys for given triggered notification.
*
* @param type
* Notification life cycle type
* @param ids
* The ID of the notification
*/
- (void) getOption:(CDVInvokedUrlCommand*)command
byType:(APPLocalNotificationType)type;
{
[self.commandDelegate runInBackground:^{
NSArray* ids = command.arguments;
NSArray* notifications;
CDVPluginResult* result;
if (type == NotifcationTypeAll) {
notifications = [self.app localNotificationOptionsById:ids];
}
else {
notifications = [self.app localNotificationOptionsByType:type
andId:ids];
}
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsDictionary:notifications[0]];
[self.commandDelegate sendPluginResult:result
callbackId:command.callbackId];
}];
}
/**
* Property list for given triggered notifications.
*
* @param type
......@@ -474,7 +528,7 @@
*/
- (void) cancelForerunnerLocalNotification:(UILocalNotification*)notification
{
NSString* id = notification.options.id;
NSNumber* id = notification.options.id;
UILocalNotification* forerunner;
forerunner = [self.app localNotificationWithId:id];
......
......@@ -25,7 +25,7 @@
- (id) initWithDict:(NSDictionary*)dict;
@property (readonly, getter=id) NSString* id;
@property (readonly, getter=id) NSNumber* id;
@property (readonly, getter=badgeNumber) NSInteger badgeNumber;
@property (readonly, getter=alertBody) NSString* alertBody;
@property (readonly, getter=soundName) NSString* soundName;
......
......@@ -59,9 +59,11 @@ NSString* const DEFAULT_SOUND = @"res://platform_default";
/**
* The notification's ID.
*/
- (NSString*) id
- (NSNumber*) id
{
return [dict objectForKey:@"id"];
NSInteger id = [[dict objectForKey:@"id"] integerValue];
return [NSNumber numberWithInteger:id];
}
/**
......@@ -186,6 +188,14 @@ NSString* const DEFAULT_SOUND = @"res://platform_default";
*/
- (NSDictionary*) userInfo
{
if ([dict objectForKey:@"updatedAt"]) {
NSMutableDictionary* data = [dict mutableCopy];
[data removeObjectForKey:@"updatedAt"];
return data;
}
return dict;
}
......
......@@ -37,14 +37,14 @@
- (NSArray*) localNotificationIdsByType:(APPLocalNotificationType)type;
// If local notification with ID exists
- (BOOL) localNotificationExist:(NSString*)id;
- (BOOL) localNotificationExist:(NSNumber*)id;
// If local notification with ID and type exists
- (BOOL) localNotificationExist:(NSString*)id type:(APPLocalNotificationType)type;
- (BOOL) localNotificationExist:(NSNumber*)id type:(APPLocalNotificationType)type;
// Local notification by ID
- (UILocalNotification*) localNotificationWithId:(NSString*)id;
- (UILocalNotification*) localNotificationWithId:(NSNumber*)id;
// Local notification by ID and type
- (UILocalNotification*) localNotificationWithId:(NSString*)id andType:(APPLocalNotificationType)type;
- (UILocalNotification*) localNotificationWithId:(NSNumber*)id andType:(APPLocalNotificationType)type;
// Property list from all local notifications
- (NSArray*) localNotificationOptions;
......
......@@ -159,7 +159,7 @@
* @param id
* Notification ID
*/
- (BOOL) localNotificationExist:(NSString*)id
- (BOOL) localNotificationExist:(NSNumber*)id
{
return [self localNotificationWithId:id] != NULL;
}
......@@ -171,7 +171,7 @@
* @param type
* Notification life cycle type
*/
- (BOOL) localNotificationExist:(NSString*)id type:(APPLocalNotificationType)type
- (BOOL) localNotificationExist:(NSNumber*)id type:(APPLocalNotificationType)type
{
return [self localNotificationWithId:id andType:type] != NULL;
}
......@@ -182,13 +182,13 @@
* @param id
* Notification ID
*/
- (UILocalNotification*) localNotificationWithId:(NSString*)id
- (UILocalNotification*) localNotificationWithId:(NSNumber*)id
{
NSArray* notifications = self.localNotifications;
for (UILocalNotification* notification in notifications)
{
if ([notification.options.id isEqualToString:id]) {
if ([notification.options.id isEqualToNumber:id]) {
return notification;
}
}
......@@ -204,7 +204,7 @@
* @param type
* Notification life cycle type
*/
- (UILocalNotification*) localNotificationWithId:(NSString*)id andType:(APPLocalNotificationType)type
- (UILocalNotification*) localNotificationWithId:(NSNumber*)id andType:(APPLocalNotificationType)type
{
UILocalNotification* notification = [self localNotificationWithId:id];
......@@ -224,7 +224,7 @@
for (UILocalNotification* notification in notifications)
{
[options addObject:notification.userInfo];
[options addObject:notification.options.userInfo];
}
return options;
......@@ -244,7 +244,7 @@
for (UILocalNotification* notification in notifications)
{
if (notification.type == type) {
[options addObject:notification.userInfo];
[options addObject:notification.options.userInfo];
}
}
......@@ -262,12 +262,12 @@
UILocalNotification* notification;
NSMutableArray* options = [[NSMutableArray alloc] init];
for (NSString* id in ids)
for (NSNumber* id in ids)
{
notification = [self localNotificationWithId:id];
if (notification) {
[options addObject:notification.userInfo];
[options addObject:notification.options.userInfo];
}
}
......@@ -287,12 +287,12 @@
UILocalNotification* notification;
NSMutableArray* options = [[NSMutableArray alloc] init];
for (NSString* id in ids)
for (NSNumber* id in ids)
{
notification = [self localNotificationWithId:id];
if (notification && notification.type == type) {
[options addObject:notification.userInfo];
[options addObject:notification.options.userInfo];
}
}
......
......@@ -23,9 +23,6 @@
</author>
<content src="index.html" />
<access origin="*" />
<feature name="Toast">
<param name="ios-package" value="Toast" />
</feature>
<feature name="Device">
<param name="ios-package" value="CDVDevice" />
</feature>
......@@ -33,4 +30,7 @@
<param name="ios-package" onload="true" value="APPLocalNotification" />
<param name="onload" value="true" />
</feature>
<feature name="Toast">
<param name="ios-package" value="Toast" />
</feature>
</widget>
cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
{
"file": "plugins/nl.x-services.plugins.toast/www/Toast.js",
"id": "nl.x-services.plugins.toast.Toast",
"clobbers": [
"window.plugins.toast"
]
},
{
"file": "plugins/nl.x-services.plugins.toast/test/tests.js",
"id": "nl.x-services.plugins.toast.tests"
},
{
"file": "plugins/de.appplant.cordova.plugin.local-notification/www/local-notification.js",
"id": "de.appplant.cordova.plugin.local-notification.LocalNotification",
"clobbers": [
......@@ -36,6 +25,17 @@ module.exports = [
]
},
{
"file": "plugins/nl.x-services.plugins.toast/www/Toast.js",
"id": "nl.x-services.plugins.toast.Toast",
"clobbers": [
"window.plugins.toast"
]
},
{
"file": "plugins/nl.x-services.plugins.toast/test/tests.js",
"id": "nl.x-services.plugins.toast.tests"
},
{
"file": "plugins/org.apache.cordova.device/www/device.js",
"id": "org.apache.cordova.device.device",
"clobbers": [
......@@ -46,8 +46,8 @@ module.exports = [
module.exports.metadata =
// TOP OF METADATA
{
"nl.x-services.plugins.toast": "2.0.3",
"de.appplant.cordova.plugin.local-notification": "0.8.2dev",
"nl.x-services.plugins.toast": "2.0.3",
"org.apache.cordova.device": "0.3.0"
}
// BOTTOM OF METADATA
......
......@@ -172,9 +172,7 @@ exports.cancelAll = function (callback, scope) {
* The scope for the callback function
*/
exports.isPresent = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('isPresent', notId, callback, scope);
this.exec('isPresent', id || 0, callback, scope);
};
/**
......@@ -188,9 +186,7 @@ exports.isPresent = function (id, callback, scope) {
* The scope for the callback function
*/
exports.isScheduled = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('isScheduled', notId, callback, scope);
this.exec('isScheduled', id || 0, callback, scope);
};
/**
......@@ -204,9 +200,7 @@ exports.isScheduled = function (id, callback, scope) {
* The scope for the callback function
*/
exports.isTriggered = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('isTriggered', notId, callback, scope);
this.exec('isTriggered', id || 0, callback, scope);
};
/**
......@@ -275,7 +269,7 @@ exports.get = function () {
scope = args[2];
if (!Array.isArray(ids)) {
this.exec('getSingle', ids.toString(), callback, scope);
this.exec('getSingle', Number(ids), callback, scope);
return;
}
......@@ -323,7 +317,7 @@ exports.getScheduled = function () {
}
if (!Array.isArray(ids)) {
this.exec('getSingleScheduled', ids.toString(), callback, scope);
this.exec('getSingleScheduled', Number(ids), callback, scope);
return;
}
......@@ -371,7 +365,7 @@ exports.getTriggered = function () {
}
if (!Array.isArray(ids)) {
this.exec('getSingleTriggered', ids.toString(), callback, scope);
this.exec('getSingleTriggered', Number(ids), callback, scope);
return;
}
......
......@@ -35,7 +35,7 @@ exports._defaults = {
title: '',
sound: 'res://platform_default',
badge: 0,
id: "0",
id: 0,
data: undefined,
every: undefined,
at: undefined
......@@ -87,7 +87,9 @@ exports.mergeWithDefaults = function (options) {
options.text = this.getValueFor(options, 'text', 'message');
options.data = this.getValueFor(options, 'data', 'json');
options.autoClear = this.getValueFor(options, 'autoClear', 'autoCancel');
if (defaults.hasOwnProperty('autoClear')) {
options.autoClear = this.getValueFor(options, 'autoClear', 'autoCancel');
}
if (options.autoClear !== true && options.ongoing) {
options.autoClear = false;
......@@ -131,8 +133,9 @@ exports.convertProperties = function (options) {
if (options.id) {
if (isNaN(options.id)) {
options.id = this.getDefaults().id;
console.warn('Id is not a number: ' + options.id);
} else {
options.id = options.id.toString();
options.id = Number(options.id);
}
}
......@@ -147,13 +150,18 @@ exports.convertProperties = function (options) {
if (options.badge) {
if (isNaN(options.badge)) {
options.badge = this.getDefaults().badge;
console.warn('Badge number is not a number: ' + options.id);
} else {
options.badge = Number(options.badge);
}
}
if (typeof options.at == 'object') {
options.at = Math.round(options.at.getTime()/1000);
if (options.at) {
if (typeof options.at == 'object') {
options.at = options.at.getTime();
}
options.at = Math.round(options.at/1000);
}
if (typeof options.data == 'object') {
......@@ -175,6 +183,7 @@ exports.convertProperties = function (options) {
* The new callback function
*/
exports.createCallbackFn = function (callbackFn, scope) {
if (typeof callbackFn != 'function')
return;
......@@ -184,17 +193,17 @@ exports.createCallbackFn = function (callbackFn, scope) {
};
/**
* Convert the IDs to Strings.
* Convert the IDs to numbers.
*
* @param {String/Number[]} ids
*
* @return Array of Strings
* @return Array of Numbers
*/
exports.convertIds = function (ids) {
var convertedIds = [];
for (var i = 0; i < ids.length; i++) {
convertedIds.push(ids[i].toString());
convertedIds.push(Number(ids[i]));
}
return convertedIds;
......
cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
{
"file": "plugins/nl.x-services.plugins.toast/www/Toast.js",
"id": "nl.x-services.plugins.toast.Toast",
"clobbers": [
"window.plugins.toast"
]
},
{
"file": "plugins/nl.x-services.plugins.toast/test/tests.js",
"id": "nl.x-services.plugins.toast.tests"
},
{
"file": "plugins/de.appplant.cordova.plugin.local-notification/www/local-notification.js",
"id": "de.appplant.cordova.plugin.local-notification.LocalNotification",
"clobbers": [
......@@ -46,17 +57,6 @@ module.exports = [
]
},
{
"file": "plugins/nl.x-services.plugins.toast/www/Toast.js",
"id": "nl.x-services.plugins.toast.Toast",
"clobbers": [
"window.plugins.toast"
]
},
{
"file": "plugins/nl.x-services.plugins.toast/test/tests.js",
"id": "nl.x-services.plugins.toast.tests"
},
{
"file": "plugins/org.apache.cordova.device/www/device.js",
"id": "org.apache.cordova.device.device",
"clobbers": [
......@@ -74,8 +74,8 @@ module.exports = [
module.exports.metadata =
// TOP OF METADATA
{
"de.appplant.cordova.plugin.local-notification": "0.8.2dev",
"nl.x-services.plugins.toast": "2.0.3",
"de.appplant.cordova.plugin.local-notification": "0.8.2dev",
"org.apache.cordova.device": "0.3.0"
}
// BOTTOM OF METADATA
......
......@@ -209,6 +209,54 @@ exports.getTriggeredIds = function (success, error) {
};
/**
* Propertys for given notification.
*
* @param {Function} success
* Success callback
* @param {Function} error
* Error callback
* @param {int[]} ids
* List of local notification IDs
*/
exports.getSingle = function (success, error, ids) {
var notification = exports.core.getAll(ids)[0];
success(notification);
};
/**
* Propertys for given scheduled notification.
*
* @param {Function} success
* Success callback
* @param {Function} error
* Error callback
* @param {int[]} ids
* List of local notification IDs
*/
exports.getSingleScheduled = function (success, error, ids) {
var notification = exports.core.getScheduled(ids)[0];
success(notification);
};
/**
* Propertys for given triggered notification.
*
* @param {Function} success
* Success callback
* @param {Function} error
* Error callback
* @param {int[]} ids
* List of local notification IDs
*/
exports.getSingleTriggered = function (success, error, ids) {
var notification = exports.core.getTriggered(ids)[0];
success(notification);
};
/**
* Property list for given notifications.
* If called without IDs, all notification will be returned.
*
......
......@@ -20,8 +20,8 @@ cordova.define("de.appplant.cordova.plugin.local-notification.LocalNotification.
*/
exports = require('de.appplant.cordova.plugin.local-notification.LocalNotification.Proxy').core;
exports = require('de.appplant.cordova.plugin.local-notification.LocalNotification.Proxy').core;
var channel = require('cordova/channel');
......
......@@ -172,9 +172,7 @@ exports.cancelAll = function (callback, scope) {
* The scope for the callback function
*/
exports.isPresent = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('isPresent', notId, callback, scope);
this.exec('isPresent', id || 0, callback, scope);
};
/**
......@@ -188,9 +186,7 @@ exports.isPresent = function (id, callback, scope) {
* The scope for the callback function
*/
exports.isScheduled = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('isScheduled', notId, callback, scope);
this.exec('isScheduled', id || 0, callback, scope);
};
/**
......@@ -204,9 +200,7 @@ exports.isScheduled = function (id, callback, scope) {
* The scope for the callback function
*/
exports.isTriggered = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('isTriggered', notId, callback, scope);
this.exec('isTriggered', id || 0, callback, scope);
};
/**
......@@ -275,7 +269,7 @@ exports.get = function () {
scope = args[2];
if (!Array.isArray(ids)) {
this.exec('getSingle', ids.toString(), callback, scope);
this.exec('getSingle', Number(ids), callback, scope);
return;
}
......@@ -323,7 +317,7 @@ exports.getScheduled = function () {
}
if (!Array.isArray(ids)) {
this.exec('getSingleScheduled', ids.toString(), callback, scope);
this.exec('getSingleScheduled', Number(ids), callback, scope);
return;
}
......@@ -371,7 +365,7 @@ exports.getTriggered = function () {
}
if (!Array.isArray(ids)) {
this.exec('getSingleTriggered', ids.toString(), callback, scope);
this.exec('getSingleTriggered', Number(ids), callback, scope);
return;
}
......
......@@ -35,7 +35,7 @@ exports._defaults = {
title: '',
sound: 'res://platform_default',
badge: 0,
id: "0",
id: 0,
data: undefined,
every: undefined,
at: undefined
......@@ -87,7 +87,9 @@ exports.mergeWithDefaults = function (options) {
options.text = this.getValueFor(options, 'text', 'message');
options.data = this.getValueFor(options, 'data', 'json');
options.autoClear = this.getValueFor(options, 'autoClear', 'autoCancel');
if (defaults.hasOwnProperty('autoClear')) {
options.autoClear = this.getValueFor(options, 'autoClear', 'autoCancel');
}
if (options.autoClear !== true && options.ongoing) {
options.autoClear = false;
......@@ -131,8 +133,9 @@ exports.convertProperties = function (options) {
if (options.id) {
if (isNaN(options.id)) {
options.id = this.getDefaults().id;
console.warn('Id is not a number: ' + options.id);
} else {
options.id = options.id.toString();
options.id = Number(options.id);
}
}
......@@ -147,13 +150,18 @@ exports.convertProperties = function (options) {
if (options.badge) {
if (isNaN(options.badge)) {
options.badge = this.getDefaults().badge;
console.warn('Badge number is not a number: ' + options.id);
} else {
options.badge = Number(options.badge);
}
}
if (typeof options.at == 'object') {
options.at = Math.round(options.at.getTime()/1000);
if (options.at) {
if (typeof options.at == 'object') {
options.at = options.at.getTime();
}
options.at = Math.round(options.at/1000);
}
if (typeof options.data == 'object') {
......@@ -175,6 +183,7 @@ exports.convertProperties = function (options) {
* The new callback function
*/
exports.createCallbackFn = function (callbackFn, scope) {
if (typeof callbackFn != 'function')
return;
......@@ -184,17 +193,17 @@ exports.createCallbackFn = function (callbackFn, scope) {
};
/**
* Convert the IDs to Strings.
* Convert the IDs to numbers.
*
* @param {String/Number[]} ids
*
* @return Array of Strings
* @return Array of Numbers
*/
exports.convertIds = function (ids) {
var convertedIds = [];
for (var i = 0; i < ids.length; i++) {
convertedIds.push(ids[i].toString());
convertedIds.push(Number(ids[i]));
}
return convertedIds;
......
......@@ -20,6 +20,7 @@
<!-- cordova -->
<engines>
<engine name="cordova" version=">=3.0.0" />
<engine name="cordova" version="<4.0.0" />
</engines>
<!-- dependencies -->
......
......@@ -39,10 +39,16 @@ module.exports = function (context) {
var cordova_util = context.requireCordovaModule('cordova-lib/src/cordova/util'),
ConfigParser = context.requireCordovaModule('cordova-lib/src/configparser/ConfigParser'),
platforms = context.requireCordovaModule('cordova-lib/src/cordova/platforms'),
projectRoot = cordova_util.isCordova(),
xml = cordova_util.projectConfig(projectRoot),
cfg = new ConfigParser(xml);
// Cordova moved the platforms stuff; try both locations so we'll work for new and old file layouts.
var platforms;
try {
platforms = context.requireCordovaModule('cordova-lib/src/cordova/platforms');
} catch(e) {
platforms = context.requireCordovaModule('cordova-lib/src/platforms/platforms');
}
/**
* The absolute path for the file.
......
......@@ -23,7 +23,8 @@
package de.appplant.cordova.plugin.localnotification;
import de.appplant.cordova.plugin.notification.*;
import de.appplant.cordova.plugin.notification.Builder;
import de.appplant.cordova.plugin.notification.Notification;
import de.appplant.cordova.plugin.notification.TriggerReceiver;
/**
......
......@@ -23,8 +23,7 @@
package de.appplant.cordova.plugin.localnotification;
import java.util.ArrayList;
import java.util.List;
import android.os.Build;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
......@@ -35,9 +34,11 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.os.Build;
import java.util.ArrayList;
import java.util.List;
import de.appplant.cordova.plugin.notification.*;
import de.appplant.cordova.plugin.notification.Manager;
import de.appplant.cordova.plugin.notification.Notification;
/**
* This plugin utilizes the Android AlarmManager in combination with local
......@@ -249,7 +250,9 @@ public class LocalNotification extends CordovaPlugin {
Notification notification =
getNotificationMgr().cancel(id);
fireEvent("cancel", notification);
if (notification != null) {
fireEvent("cancel", notification);
}
}
}
......@@ -274,7 +277,9 @@ public class LocalNotification extends CordovaPlugin {
Notification notification =
getNotificationMgr().clear(id);
fireEvent("clear", notification);
if (notification != null) {
fireEvent("clear", notification);
}
}
}
......
......@@ -42,7 +42,9 @@ public class RestoreReceiver extends AbstractRestoreReceiver {
*/
@Override
public void onRestore (Notification notification) {
notification.schedule();
if (notification.isScheduled()) {
notification.schedule();
}
}
/**
......
......@@ -23,7 +23,8 @@
package de.appplant.cordova.plugin.localnotification;
import de.appplant.cordova.plugin.notification.*;
import de.appplant.cordova.plugin.notification.Builder;
import de.appplant.cordova.plugin.notification.Notification;
/**
* The alarm receiver is triggered when a scheduled alarm is fired. This class
......
......@@ -23,16 +23,6 @@
package de.appplant.cordova.plugin.notification;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
......@@ -43,6 +33,16 @@ import android.net.Uri;
import android.os.StrictMode;
import android.util.Log;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
/**
* Util class to map unified asset URIs to native URIs. URIs like file:///
* map to absolute paths while file:// point relatively to the www folder
......@@ -60,7 +60,7 @@ class AssetUtil {
// Ref to the context passed through the constructor to access the
// resources and app directory.
private final Context context;
/**
* Constructor
*
......@@ -102,7 +102,7 @@ class AssetUtil {
/**
* The URI for a path.
*
*
* @param path
* The given path
*/
......@@ -120,15 +120,13 @@ class AssetUtil {
return Uri.EMPTY;
}
/**
* URI for a file.
*
*
* @param path
* Absolute path like file:///...
*
*
* @return
* URI pointing to the given path
*/
......@@ -146,10 +144,10 @@ class AssetUtil {
/**
* URI for an asset.
*
*
* @param path
* Asset path like file://...
*
*
* @return
* URI pointing to the given path
*/
......@@ -191,10 +189,10 @@ class AssetUtil {
/**
* The URI for a resource.
*
*
* @param path
* The given relative path
*
*
* @return
* URI pointing to the given path
*/
......@@ -240,7 +238,7 @@ class AssetUtil {
return Uri.EMPTY;
}
/**
* Uri from remote located content.
*
......@@ -286,11 +284,11 @@ class AssetUtil {
outStream.flush();
outStream.close();
return Uri.fromFile(file);
} catch (MalformedURLException e) {
Log.e("Asset", "Incorrect URL");
Log.e("Asset", "Incorrect URL");
e.printStackTrace();
} catch (FileNotFoundException e) {
Log.e("Asset", "Failed to create new File from HTTP Content");
......@@ -305,7 +303,7 @@ class AssetUtil {
/**
* Copy content from input stream into output stream.
*
*
* @param in
* The input stream
* @param out
......
......@@ -23,8 +23,6 @@
package de.appplant.cordova.plugin.notification;
import java.util.Random;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
......@@ -33,6 +31,8 @@ import android.support.v4.app.NotificationCompat;
import org.json.JSONObject;
import java.util.Random;
/**
* Builder class for local notifications. Build fully configured local
* notification specified by JSON object passed from JS side.
......@@ -158,7 +158,7 @@ public class Builder {
return;
Intent deleteIntent = new Intent(context, clearReceiver)
.setAction(options.getId())
.setAction(options.getIdStr())
.putExtra(Options.EXTRA, options.toString());
PendingIntent dpi = PendingIntent.getBroadcast(
......
......@@ -23,8 +23,6 @@
package de.appplant.cordova.plugin.notification;
import static de.appplant.cordova.plugin.notification.Notification.PREF_KEY;
import android.app.NotificationManager;
import android.content.Context;
import android.content.SharedPreferences;
......@@ -34,12 +32,13 @@ import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static de.appplant.cordova.plugin.notification.Notification.PREF_KEY;
/**
* Central way to access all or single local notifications set by specific
* state like triggered or scheduled. Offers shortcut ways to schedule,
......
......@@ -45,7 +45,7 @@ import java.util.Date;
public class Notification {
// Used to differ notifications by their life cycle state
public static enum Type {
public enum Type {
ALL, SCHEDULED, TRIGGERED
}
......@@ -105,7 +105,7 @@ public class Notification {
* Get notification ID.
*/
public int getId () {
return options.getIdAsInt();
return options.getId();
}
/**
......@@ -162,27 +162,23 @@ public class Notification {
* Schedule the local notification.
*/
public void schedule() {
long triggerTime = getNextTriggerTime();
long triggerTime = options.getTriggerTime();
persist();
// Intent gets called when the Notification gets fired
Intent intent = new Intent(context, receiver)
.setAction(options.getId())
.setAction(options.getIdStr())
.putExtra(Options.EXTRA, options.toString());
PendingIntent pi = PendingIntent.getBroadcast(
context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
getAlarmMgr().set(AlarmManager.RTC_WAKEUP, triggerTime, pi);
}
/**
* Re-schedule the local notification if repeating.
*/
void reschedule () {
if (isRepeating()) {
schedule();
getAlarmMgr().setRepeating(AlarmManager.RTC_WAKEUP,
triggerTime, options.getRepeatInterval(), pi);
} else {
getAlarmMgr().set(AlarmManager.RTC_WAKEUP, triggerTime, pi);
}
}
......@@ -208,13 +204,13 @@ public class Notification {
*/
public void cancel() {
Intent intent = new Intent(context, receiver)
.setAction(options.getId());
.setAction(options.getIdStr());
PendingIntent pi = PendingIntent.
getBroadcast(context, 0, intent, 0);
getAlarmMgr().cancel(pi);
getNotMgr().cancel(options.getIdAsInt());
getNotMgr().cancel(options.getId());
unpersist();
}
......@@ -232,7 +228,7 @@ public class Notification {
*/
@SuppressWarnings("deprecation")
private void showNotification () {
int id = getOptions().getIdAsInt();
int id = getOptions().getId();
if (Build.VERSION.SDK_INT <= 15) {
// Notification for HoneyComb to ICS
......@@ -251,26 +247,11 @@ public class Notification {
}
/**
* Next trigger time.
*/
public long getNextTriggerTime() {
long triggerTime = options.getTriggerTime();
if (!isRepeating() || !isTriggered())
return triggerTime;
long interval = options.getRepeatInterval();
int triggerCount = getTriggerCountSinceSchedule();
return triggerTime + (triggerCount + 1) * interval;
}
/**
* Count of triggers since schedule.
*/
public int getTriggerCountSinceSchedule() {
long now = System.currentTimeMillis();
long initTriggerTime = options.getTriggerTime();
long triggerTime = options.getTriggerTime();
if (!wasInThePast())
return 0;
......@@ -278,7 +259,7 @@ public class Notification {
if (!isRepeating())
return 1;
return (int) ((now - initTriggerTime) / options.getRepeatInterval());
return (int) ((now - triggerTime) / options.getRepeatInterval());
}
/**
......@@ -294,6 +275,7 @@ public class Notification {
e.printStackTrace();
}
json.remove("firstAt");
json.remove("updatedAt");
json.remove("soundUri");
json.remove("iconUri");
......@@ -309,7 +291,7 @@ public class Notification {
private void persist () {
SharedPreferences.Editor editor = getPrefs().edit();
editor.putString(options.getId(), options.toString());
editor.putString(options.getIdStr(), options.toString());
if (Build.VERSION.SDK_INT < 9) {
editor.commit();
......@@ -324,7 +306,7 @@ public class Notification {
private void unpersist () {
SharedPreferences.Editor editor = getPrefs().edit();
editor.remove(options.getId());
editor.remove(options.getIdStr());
if (Build.VERSION.SDK_INT < 9) {
editor.commit();
......
......@@ -23,16 +23,16 @@
package de.appplant.cordova.plugin.notification;
import java.util.Date;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.AlarmManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Date;
/**
* Wrapper around the JSON object passed through JS which contains all
* possible option values. Class provides simple readers and more advanced
......@@ -189,35 +189,34 @@ public class Options {
}
/**
* Trigger date in milliseconds.
* ID for the local notification as a number.
*/
public long getTriggerTime() {
return options.optLong("at", 0) * 1000;
public Integer getId() {
return options.optInt("id", 0);
}
/**
* Trigger date.
* ID for the local notification as a string.
*/
public Date getTriggerDate() {
return new Date(getTriggerTime());
public String getIdStr() {
return getId().toString();
}
/**
* ID for the local notification.
* Trigger date.
*/
public String getId() {
return options.optString("id", "0");
public Date getTriggerDate() {
return new Date(getTriggerTime());
}
/**
* ID for the local notification.
* Trigger date in milliseconds.
*/
public int getIdAsInt() {
try {
return Integer.parseInt(getId());
} catch (Exception ignore) {
return 0;
}
public long getTriggerTime() {
return Math.max(
System.currentTimeMillis(),
options.optLong("at", 0) * 1000
);
}
/**
......
......@@ -42,11 +42,6 @@ public class TriggerReceiver extends AbstractTriggerReceiver {
*/
@Override
public void onTrigger (Notification notification, boolean updated) {
if (notification.isRepeating()) {
notification.reschedule();
}
notification.show();
}
......
......@@ -61,6 +61,13 @@
// List all ids from all triggered notifications
- (void) getTriggeredIds:(CDVInvokedUrlCommand*)command;
// Propertys for given local notification
- (void) getSingle:(CDVInvokedUrlCommand*)command;
// Propertya for given scheduled notification
- (void) getSingleScheduled:(CDVInvokedUrlCommand*)command;
// Propertys for given triggered notification
- (void) getSingleTriggered:(CDVInvokedUrlCommand*)command;
// Property list for given local notifications
- (void) getAll:(CDVInvokedUrlCommand*)command;
// Property list for given scheduled notifications
......
......@@ -102,7 +102,7 @@
[self.commandDelegate runInBackground:^{
for (NSDictionary* options in notifications) {
NSString* id = [options objectForKey:@"id"];
NSNumber* id = [options objectForKey:@"id"];
UILocalNotification* notification;
notification = [self.app localNotificationWithId:id];
......@@ -133,7 +133,7 @@
- (void) cancel:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
for (NSString* id in command.arguments) {
for (NSNumber* id in command.arguments) {
UILocalNotification* notification;
notification = [self.app localNotificationWithId:id];
......@@ -170,7 +170,7 @@
- (void) clear:(CDVInvokedUrlCommand*)command
{
[self.commandDelegate runInBackground:^{
for (NSString* id in command.arguments) {
for (NSNumber* id in command.arguments) {
UILocalNotification* notification;
notification = [self.app localNotificationWithId:id];
......@@ -241,7 +241,7 @@
type:(APPLocalNotificationType)type;
{
[self.commandDelegate runInBackground:^{
NSString* id = [command argumentAtIndex:0];
NSNumber* id = [command argumentAtIndex:0];
BOOL exist;
CDVPluginResult* result;
......@@ -314,6 +314,28 @@
}
/**
* Propertys for given local notification.
*/
- (void) getSingle:(CDVInvokedUrlCommand*)command
{
[self getOption:command byType:NotifcationTypeAll];
}
/**
* Propertya for given scheduled notification.
*/
- (void) getSingleScheduled:(CDVInvokedUrlCommand*)command
{
[self getOption:command byType:NotifcationTypeScheduled];
}
// Propertys for given triggered notification
- (void) getSingleTriggered:(CDVInvokedUrlCommand*)command
{
[self getOption:command byType:NotifcationTypeTriggered];
}
/**
* Property list for given local notifications.
*
* @param ids
......@@ -347,6 +369,38 @@
}
/**
* Propertys for given triggered notification.
*
* @param type
* Notification life cycle type
* @param ids
* The ID of the notification
*/
- (void) getOption:(CDVInvokedUrlCommand*)command
byType:(APPLocalNotificationType)type;
{
[self.commandDelegate runInBackground:^{
NSArray* ids = command.arguments;
NSArray* notifications;
CDVPluginResult* result;
if (type == NotifcationTypeAll) {
notifications = [self.app localNotificationOptionsById:ids];
}
else {
notifications = [self.app localNotificationOptionsByType:type
andId:ids];
}
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsDictionary:notifications[0]];
[self.commandDelegate sendPluginResult:result
callbackId:command.callbackId];
}];
}
/**
* Property list for given triggered notifications.
*
* @param type
......@@ -474,7 +528,7 @@
*/
- (void) cancelForerunnerLocalNotification:(UILocalNotification*)notification
{
NSString* id = notification.options.id;
NSNumber* id = notification.options.id;
UILocalNotification* forerunner;
forerunner = [self.app localNotificationWithId:id];
......
......@@ -25,7 +25,7 @@
- (id) initWithDict:(NSDictionary*)dict;
@property (readonly, getter=id) NSString* id;
@property (readonly, getter=id) NSNumber* id;
@property (readonly, getter=badgeNumber) NSInteger badgeNumber;
@property (readonly, getter=alertBody) NSString* alertBody;
@property (readonly, getter=soundName) NSString* soundName;
......
......@@ -59,9 +59,11 @@ NSString* const DEFAULT_SOUND = @"res://platform_default";
/**
* The notification's ID.
*/
- (NSString*) id
- (NSNumber*) id
{
return [dict objectForKey:@"id"];
NSInteger id = [[dict objectForKey:@"id"] integerValue];
return [NSNumber numberWithInteger:id];
}
/**
......@@ -186,6 +188,14 @@ NSString* const DEFAULT_SOUND = @"res://platform_default";
*/
- (NSDictionary*) userInfo
{
if ([dict objectForKey:@"updatedAt"]) {
NSMutableDictionary* data = [dict mutableCopy];
[data removeObjectForKey:@"updatedAt"];
return data;
}
return dict;
}
......
......@@ -37,14 +37,14 @@
- (NSArray*) localNotificationIdsByType:(APPLocalNotificationType)type;
// If local notification with ID exists
- (BOOL) localNotificationExist:(NSString*)id;
- (BOOL) localNotificationExist:(NSNumber*)id;
// If local notification with ID and type exists
- (BOOL) localNotificationExist:(NSString*)id type:(APPLocalNotificationType)type;
- (BOOL) localNotificationExist:(NSNumber*)id type:(APPLocalNotificationType)type;
// Local notification by ID
- (UILocalNotification*) localNotificationWithId:(NSString*)id;
- (UILocalNotification*) localNotificationWithId:(NSNumber*)id;
// Local notification by ID and type
- (UILocalNotification*) localNotificationWithId:(NSString*)id andType:(APPLocalNotificationType)type;
- (UILocalNotification*) localNotificationWithId:(NSNumber*)id andType:(APPLocalNotificationType)type;
// Property list from all local notifications
- (NSArray*) localNotificationOptions;
......
......@@ -159,7 +159,7 @@
* @param id
* Notification ID
*/
- (BOOL) localNotificationExist:(NSString*)id
- (BOOL) localNotificationExist:(NSNumber*)id
{
return [self localNotificationWithId:id] != NULL;
}
......@@ -171,7 +171,7 @@
* @param type
* Notification life cycle type
*/
- (BOOL) localNotificationExist:(NSString*)id type:(APPLocalNotificationType)type
- (BOOL) localNotificationExist:(NSNumber*)id type:(APPLocalNotificationType)type
{
return [self localNotificationWithId:id andType:type] != NULL;
}
......@@ -182,13 +182,13 @@
* @param id
* Notification ID
*/
- (UILocalNotification*) localNotificationWithId:(NSString*)id
- (UILocalNotification*) localNotificationWithId:(NSNumber*)id
{
NSArray* notifications = self.localNotifications;
for (UILocalNotification* notification in notifications)
{
if ([notification.options.id isEqualToString:id]) {
if ([notification.options.id isEqualToNumber:id]) {
return notification;
}
}
......@@ -204,7 +204,7 @@
* @param type
* Notification life cycle type
*/
- (UILocalNotification*) localNotificationWithId:(NSString*)id andType:(APPLocalNotificationType)type
- (UILocalNotification*) localNotificationWithId:(NSNumber*)id andType:(APPLocalNotificationType)type
{
UILocalNotification* notification = [self localNotificationWithId:id];
......@@ -224,7 +224,7 @@
for (UILocalNotification* notification in notifications)
{
[options addObject:notification.userInfo];
[options addObject:notification.options.userInfo];
}
return options;
......@@ -244,7 +244,7 @@
for (UILocalNotification* notification in notifications)
{
if (notification.type == type) {
[options addObject:notification.userInfo];
[options addObject:notification.options.userInfo];
}
}
......@@ -262,12 +262,12 @@
UILocalNotification* notification;
NSMutableArray* options = [[NSMutableArray alloc] init];
for (NSString* id in ids)
for (NSNumber* id in ids)
{
notification = [self localNotificationWithId:id];
if (notification) {
[options addObject:notification.userInfo];
[options addObject:notification.options.userInfo];
}
}
......@@ -287,12 +287,12 @@
UILocalNotification* notification;
NSMutableArray* options = [[NSMutableArray alloc] init];
for (NSString* id in ids)
for (NSNumber* id in ids)
{
notification = [self localNotificationWithId:id];
if (notification && notification.type == type) {
[options addObject:notification.userInfo];
[options addObject:notification.options.userInfo];
}
}
......
......@@ -20,12 +20,12 @@
*/
var Notifications = Windows.UI.Notifications,
applicationData = Windows.Storage.ApplicationData.current,
localSettings = applicationData.localSettings;
var proxy = require('de.appplant.cordova.plugin.local-notification.LocalNotification.Proxy');
var Notifications = Windows.UI.Notifications;
exports.core = {
proxy.core = {
/**
* Executes all queued events.
......
......@@ -209,6 +209,54 @@ exports.getTriggeredIds = function (success, error) {
};
/**
* Propertys for given notification.
*
* @param {Function} success
* Success callback
* @param {Function} error
* Error callback
* @param {int[]} ids
* List of local notification IDs
*/
exports.getSingle = function (success, error, ids) {
var notification = exports.core.getAll(ids)[0];
success(notification);
};
/**
* Propertys for given scheduled notification.
*
* @param {Function} success
* Success callback
* @param {Function} error
* Error callback
* @param {int[]} ids
* List of local notification IDs
*/
exports.getSingleScheduled = function (success, error, ids) {
var notification = exports.core.getScheduled(ids)[0];
success(notification);
};
/**
* Propertys for given triggered notification.
*
* @param {Function} success
* Success callback
* @param {Function} error
* Error callback
* @param {int[]} ids
* List of local notification IDs
*/
exports.getSingleTriggered = function (success, error, ids) {
var notification = exports.core.getTriggered(ids)[0];
success(notification);
};
/**
* Property list for given notifications.
* If called without IDs, all notification will be returned.
*
......@@ -259,11 +307,5 @@ exports.getTriggered = function (success, error, ids) {
success(notifications);
};
/**
* Required for core module to access the proxy.
*/
exports.exports = function () {
return exports;
};
cordova.commandProxy.add('LocalNotification', exports);
......@@ -20,9 +20,9 @@
*/
var channel = require('cordova/channel');
exports = require('de.appplant.cordova.plugin.local-notification.LocalNotification.Proxy').core;
exports = require('de.appplant.cordova.plugin.local-notification.LocalNotification.Proxy.Core').core;
var channel = require('cordova/channel');
/***********
......
......@@ -172,9 +172,7 @@ exports.cancelAll = function (callback, scope) {
* The scope for the callback function
*/
exports.isPresent = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('isPresent', notId, callback, scope);
this.exec('isPresent', id || 0, callback, scope);
};
/**
......@@ -188,9 +186,7 @@ exports.isPresent = function (id, callback, scope) {
* The scope for the callback function
*/
exports.isScheduled = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('isScheduled', notId, callback, scope);
this.exec('isScheduled', id || 0, callback, scope);
};
/**
......@@ -204,9 +200,7 @@ exports.isScheduled = function (id, callback, scope) {
* The scope for the callback function
*/
exports.isTriggered = function (id, callback, scope) {
var notId = (id || '0').toString();
this.exec('isTriggered', notId, callback, scope);
this.exec('isTriggered', id || 0, callback, scope);
};
/**
......@@ -275,7 +269,7 @@ exports.get = function () {
scope = args[2];
if (!Array.isArray(ids)) {
this.exec('getSingle', ids.toString(), callback, scope);
this.exec('getSingle', Number(ids), callback, scope);
return;
}
......@@ -323,7 +317,7 @@ exports.getScheduled = function () {
}
if (!Array.isArray(ids)) {
this.exec('getSingleScheduled', ids.toString(), callback, scope);
this.exec('getSingleScheduled', Number(ids), callback, scope);
return;
}
......@@ -371,7 +365,7 @@ exports.getTriggered = function () {
}
if (!Array.isArray(ids)) {
this.exec('getSingleTriggered', ids.toString(), callback, scope);
this.exec('getSingleTriggered', Number(ids), callback, scope);
return;
}
......
......@@ -35,7 +35,7 @@ exports._defaults = {
title: '',
sound: 'res://platform_default',
badge: 0,
id: "0",
id: 0,
data: undefined,
every: undefined,
at: undefined
......@@ -87,7 +87,9 @@ exports.mergeWithDefaults = function (options) {
options.text = this.getValueFor(options, 'text', 'message');
options.data = this.getValueFor(options, 'data', 'json');
options.autoClear = this.getValueFor(options, 'autoClear', 'autoCancel');
if (defaults.hasOwnProperty('autoClear')) {
options.autoClear = this.getValueFor(options, 'autoClear', 'autoCancel');
}
if (options.autoClear !== true && options.ongoing) {
options.autoClear = false;
......@@ -131,8 +133,9 @@ exports.convertProperties = function (options) {
if (options.id) {
if (isNaN(options.id)) {
options.id = this.getDefaults().id;
console.warn('Id is not a number: ' + options.id);
} else {
options.id = options.id.toString();
options.id = Number(options.id);
}
}
......@@ -147,13 +150,18 @@ exports.convertProperties = function (options) {
if (options.badge) {
if (isNaN(options.badge)) {
options.badge = this.getDefaults().badge;
console.warn('Badge number is not a number: ' + options.id);
} else {
options.badge = Number(options.badge);
}
}
if (typeof options.at == 'object') {
options.at = Math.round(options.at.getTime()/1000);
if (options.at) {
if (typeof options.at == 'object') {
options.at = options.at.getTime();
}
options.at = Math.round(options.at/1000);
}
if (typeof options.data == 'object') {
......@@ -175,6 +183,7 @@ exports.convertProperties = function (options) {
* The new callback function
*/
exports.createCallbackFn = function (callbackFn, scope) {
if (typeof callbackFn != 'function')
return;
......@@ -184,17 +193,17 @@ exports.createCallbackFn = function (callbackFn, scope) {
};
/**
* Convert the IDs to Strings.
* Convert the IDs to numbers.
*
* @param {String/Number[]} ids
*
* @return Array of Strings
* @return Array of Numbers
*/
exports.convertIds = function (ids) {
var convertedIds = [];
for (var i = 0; i < ids.length; i++) {
convertedIds.push(ids[i].toString());
convertedIds.push(Number(ids[i]));
}
return convertedIds;
......
......@@ -9,15 +9,15 @@
"parents": {
"/*": [
{
"xml": "<feature name=\"Toast\"><param name=\"ios-package\" value=\"Toast\" /></feature>",
"xml": "<feature name=\"Device\"><param name=\"ios-package\" value=\"CDVDevice\" /></feature>",
"count": 1
},
{
"xml": "<feature name=\"Device\"><param name=\"ios-package\" value=\"CDVDevice\" /></feature>",
"xml": "<feature name=\"LocalNotification\"><param name=\"ios-package\" onload=\"true\" value=\"APPLocalNotification\" /><param name=\"onload\" value=\"true\" /></feature>",
"count": 1
},
{
"xml": "<feature name=\"LocalNotification\"><param name=\"ios-package\" onload=\"true\" value=\"APPLocalNotification\" /><param name=\"onload\" value=\"true\" /></feature>",
"xml": "<feature name=\"Toast\"><param name=\"ios-package\" value=\"Toast\" /></feature>",
"count": 1
}
]
......@@ -30,17 +30,16 @@
"xml": false,
"count": 1
}
],
"MessageUI.framework": []
]
}
}
}
},
"installed_plugins": {
"nl.x-services.plugins.toast": {
"de.appplant.cordova.plugin.local-notification": {
"PACKAGE_NAME": "de.appplant.localnotification.example"
},
"de.appplant.cordova.plugin.local-notification": {
"nl.x-services.plugins.toast": {
"PACKAGE_NAME": "de.appplant.localnotification.example"
}
},
......
......@@ -7,10 +7,10 @@
"files": {}
},
"installed_plugins": {
"de.appplant.cordova.plugin.local-notification": {
"nl.x-services.plugins.toast": {
"PACKAGE_NAME": "NotificationExample"
},
"nl.x-services.plugins.toast": {
"de.appplant.cordova.plugin.local-notification": {
"PACKAGE_NAME": "NotificationExample"
}
},
......
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