Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cordova-plugin-local-notifications
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nabil Sadki
cordova-plugin-local-notifications
Commits
b9bb89a9
Commit
b9bb89a9
authored
Jan 16, 2015
by
PKnittel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented new fireEvent-method on android.
parent
ed78cdfb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
12 deletions
+38
-12
LocalNotification.java
src/android/LocalNotification.java
+38
-12
No files found.
src/android/LocalNotification.java
View file @
b9bb89a9
...
...
@@ -40,6 +40,7 @@ import android.content.Context;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences.Editor
;
import
android.os.Build
;
import
android.util.Log
;
import
android.annotation.TargetApi
;
import
de.appplant.cordova.plugin.notification.*
;
...
...
@@ -240,9 +241,9 @@ public class LocalNotification extends CordovaPlugin {
Options
options
=
new
Options
(
context
).
parse
(
arguments
);
options
.
setInitDate
();
nWrapper
.
schedule
(
options
);
JSONArray
data
=
new
JSONArray
().
put
(
options
.
getJSONObject
());
fireEvent
(
"add"
,
options
.
getId
(),
options
.
getJSON
(),
d
ata
);
}
JSONArray
fireData
=
new
JSONArray
().
put
(
options
.
getJSONObject
());
fireEvent
(
"add"
,
options
.
getId
(),
options
.
getJSON
(),
fireD
ata
);
}
}
/**
...
...
@@ -270,7 +271,7 @@ public class LocalNotification extends CordovaPlugin {
id
=
args
.
optString
(
i
);
nWrapper
.
cancel
(
id
);
JSONArray
managerId
=
new
JSONArray
().
put
(
id
);
JSONArray
data
=
new
JSONArray
().
put
(
manager
.
getAll
(
managerId
)
);
JSONArray
data
=
manager
.
getAll
(
managerId
);
fireEvent
(
"cancel"
,
id
,
""
,
data
);
}
}
...
...
@@ -303,7 +304,7 @@ public class LocalNotification extends CordovaPlugin {
id
=
args
.
optString
(
i
);
nWrapper
.
clear
(
id
);
JSONArray
managerId
=
new
JSONArray
().
put
(
id
);
JSONArray
data
=
new
JSONArray
().
put
(
manager
.
getAll
(
managerId
)
);
JSONArray
data
=
manager
.
getAll
(
managerId
);
fireEvent
(
"clear"
,
id
,
""
,
data
);
}
}
...
...
@@ -401,21 +402,20 @@ public class LocalNotification extends CordovaPlugin {
//
/**
* Fires the given event.
* Fires the given event
(Only one Callback also for multiple notifications in one action)
.
*
* @param {String} event The Name of the event
* @param
{String} id The ID of the notification
* @param
{String} json A custom (JSON) string
* @param
ids The IDs of the notifications as JSONArray
* @param
json The notifications JSONObjects in a JSONArray
*/
public
static
void
fireEvent
(
String
event
,
String
id
,
String
json
,
JSONArray
data
)
{
public
static
void
fireEvent
(
String
event
,
JSONArray
ids
,
JSONArray
json
)
{
String
state
=
getApplicationState
();
//TODO dataArray handling
String
params
=
"\""
+
id
+
"\",\""
+
state
+
"\",\\'"
+
JSONObject
.
quote
(
json
)
+
"\\'.replace(/(^\"|\"$)/g, \\'\\')"
;
// params = params + "," + dataArray;
String
params
=
ids
+
",\""
+
state
+
"\","
+
json
;
String
js
=
"setTimeout('plugin.notification.local.on"
+
event
+
"("
+
params
+
")',0)"
;
// webview may available, but callbacks needs to be executed
// after deviceready
Log
.
e
(
"FireEvent"
,
"JS-String: "
+
js
);
if
(
deviceready
==
false
)
{
eventQueue
.
add
(
js
);
}
else
{
...
...
@@ -423,6 +423,32 @@ public class LocalNotification extends CordovaPlugin {
}
}
//
/**
* Fires the given event. (Standard-method)
*
* @param {String} event The Name of the event
* @param {String} id The ID of the notification
* @param {String} json A custom (JSON) string
* @param data The notifications as JSONObject
*/
public
static
void
fireEvent
(
String
event
,
String
id
,
String
json
,
JSONArray
data
)
{
String
state
=
getApplicationState
();
String
params
=
"\""
+
id
+
"\",\""
+
state
+
"\","
+
JSONObject
.
quote
(
json
)+
","
+
data
;
String
js
=
"setTimeout('plugin.notification.local.on"
+
event
+
"("
+
params
+
")',0)"
;
// webview may available, but callbacks needs to be executed
// after deviceready
Log
.
e
(
"FireEvent"
,
"JS-String: "
+
js
);
if
(
deviceready
==
false
)
{
eventQueue
.
add
(
js
);
}
else
{
sendJavascript
(
js
);
}
}
/**
* Retrieves the application state
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment