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
c05c4e14
Commit
c05c4e14
authored
Jan 04, 2014
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added `json` property to pass custom data through the notification
parent
97b5c60b
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
7 deletions
+48
-7
README.md
README.md
+16
-1
Options.java
src/android/Options.java
+7
-0
Receiver.java
src/android/Receiver.java
+5
-1
ReceiverActivity.java
src/android/ReceiverActivity.java
+2
-1
APPLocalNotification.m
src/ios/APPLocalNotification.m
+11
-4
Options.cs
src/wp8/Options.cs
+6
-0
local-notification.js
www/local-notification.js
+1
-0
No files found.
README.md
View file @
c05c4e14
...
@@ -57,6 +57,7 @@ More informations can be found [here](https://build.phonegap.com/plugins/331).
...
@@ -57,6 +57,7 @@ More informations can be found [here](https://build.phonegap.com/plugins/331).
-
**[bugfix:]**
Callbacks are called with the ID as a number and not as a string.
-
**[bugfix:]**
Callbacks are called with the ID as a number and not as a string.
-
[
enhancement:
]
The background callback on Android is called, even the app is not running when the notification is tapped.
-
[
enhancement:
]
The background callback on Android is called, even the app is not running when the notification is tapped.
-
[
enhancement:
]
Notifications are repeated more precisely.
-
[
enhancement:
]
Notifications are repeated more precisely.
-
[
feature:
]
Added
`json`
property to pass custom data through the notification.
#### Version 0.6.3 (12.12.2013)
#### Version 0.6.3 (12.12.2013)
-
[
bugfix:
]
Black screen on Android.
-
[
bugfix:
]
Black screen on Android.
...
@@ -112,7 +113,8 @@ window.plugin.notification.local.add({
...
@@ -112,7 +113,8 @@ window.plugin.notification.local.add({
title
:
String
,
// The title of the message
title
:
String
,
// The title of the message
repeat
:
String
,
// Has the options of 'hourly', 'daily', 'weekly', 'monthly', 'yearly'
repeat
:
String
,
// Has the options of 'hourly', 'daily', 'weekly', 'monthly', 'yearly'
badge
:
Number
,
// Displays number badge to notification
badge
:
Number
,
// Displays number badge to notification
sound
:
String
,
// A sound to be played (iOS & Android)
sound
:
String
,
// A sound to be played
json
:
String
,
// Data to be passed through the notification
autoCancel
:
Boolean
,
// Setting this flag and the notification is automatically canceled when the user clicks it
autoCancel
:
Boolean
,
// Setting this flag and the notification is automatically canceled when the user clicks it
foreground
:
String
,
// A javascript function to be called if the app is running
foreground
:
String
,
// A javascript function to be called if the app is running
background
:
String
,
// A javascript function to be called if the app is in the background
background
:
String
,
// A javascript function to be called if the app is in the background
...
@@ -165,6 +167,19 @@ window.plugin.notification.local.add({ message: 'Great app!' });
...
@@ -165,6 +167,19 @@ window.plugin.notification.local.add({ message: 'Great app!' });
```
javascript
```
javascript
window
.
plugin
.
notification
.
local
.
add
({
sound
:
null
});
window
.
plugin
.
notification
.
local
.
add
({
sound
:
null
});
```
```
#### Pass data through the notification
```
javascript
window
.
plugin
.
notification
.
local
.
add
({
id
:
1
,
message
:
'I love BlackBerry!'
,
json
:
{
test
:
123
},
foreground
:
'forground'
});
function
foreground
(
id
,
json
)
{
console
.
log
(
id
,
JSON
.
parse
(
json
).
test
);
}
```
## Platform specifics
## Platform specifics
...
...
src/android/Options.java
View file @
c05c4e14
...
@@ -209,6 +209,13 @@ public class Options {
...
@@ -209,6 +209,13 @@ public class Options {
}
}
/**
/**
* Gibt die zusätzlichen Daten als String an.
*/
public
String
getJSON
()
{
return
options
.
optString
(
"json"
,
""
);
}
/**
* Gibt den Zahlwert des Icons an.
* Gibt den Zahlwert des Icons an.
*
*
* @param {String} className
* @param {String} className
...
...
src/android/Receiver.java
View file @
c05c4e14
...
@@ -185,7 +185,10 @@ public class Receiver extends BroadcastReceiver {
...
@@ -185,7 +185,10 @@ public class Receiver extends BroadcastReceiver {
// after reboot, LocalNotification.webView is always null
// after reboot, LocalNotification.webView is always null
// may be call foreground callback later
// may be call foreground callback later
if
(!
TextUtils
.
isEmpty
(
function
)
&&
LocalNotification
.
webView
!=
null
)
{
if
(!
TextUtils
.
isEmpty
(
function
)
&&
LocalNotification
.
webView
!=
null
)
{
LocalNotification
.
webView
.
sendJavascript
(
"setTimeout('"
+
function
+
"(\""
+
options
.
getId
()
+
"\")',0)"
);
String
params
=
"\""
+
options
.
getId
()
+
"\",\\'"
+
JSONObject
.
quote
(
options
.
getJSON
())
+
"\\'.replace(/(^\"|\"$)/g, \\'\\')"
;
String
js
=
"setTimeout('"
+
function
+
"("
+
params
+
")',0)"
;
LocalNotification
.
webView
.
sendJavascript
(
js
);
}
}
}
}
}
}
\ No newline at end of file
src/android/ReceiverActivity.java
View file @
c05c4e14
...
@@ -79,7 +79,8 @@ public class ReceiverActivity extends Activity {
...
@@ -79,7 +79,8 @@ public class ReceiverActivity extends Activity {
if
(
TextUtils
.
isEmpty
(
function
))
if
(
TextUtils
.
isEmpty
(
function
))
return
;
return
;
final
String
js
=
"setTimeout('"
+
function
+
"(\""
+
options
.
getId
()
+
"\")',0)"
;
String
params
=
"\""
+
options
.
getId
()
+
"\",\\'"
+
JSONObject
.
quote
(
options
.
getJSON
())
+
"\\'.replace(/(^\"|\"$)/g, \\'\\')"
;
final
String
js
=
"setTimeout('"
+
function
+
"("
+
params
+
")',0)"
;
// after reboot, LocalNotification.webView is always null
// after reboot, LocalNotification.webView is always null
// call background callback later
// call background callback later
...
...
src/ios/APPLocalNotification.m
View file @
c05c4e14
...
@@ -41,7 +41,6 @@
...
@@ -41,7 +41,6 @@
// Schlüssel-Präfix für alle archivierten Meldungen
// Schlüssel-Präfix für alle archivierten Meldungen
NSString
*
const
kAPP_LOCALNOTIFICATION
=
@"APP_LOCALNOTIFICATION"
;
NSString
*
const
kAPP_LOCALNOTIFICATION
=
@"APP_LOCALNOTIFICATION"
;
@implementation
APPLocalNotification
@implementation
APPLocalNotification
/**
/**
...
@@ -167,8 +166,14 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION";
...
@@ -167,8 +166,14 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION";
NSString
*
bg
=
[
options
objectForKey
:
@"background"
];
NSString
*
bg
=
[
options
objectForKey
:
@"background"
];
NSString
*
fg
=
[
options
objectForKey
:
@"foreground"
];
NSString
*
fg
=
[
options
objectForKey
:
@"foreground"
];
NSString
*
ac
=
[
options
objectForKey
:
@"autoCancel"
];
NSString
*
ac
=
[
options
objectForKey
:
@"autoCancel"
];
NSString
*
js
=
[
options
objectForKey
:
@"json"
];
return
[
NSDictionary
dictionaryWithObjectsAndKeys
:
id
,
@"id"
,
bg
,
@"background"
,
fg
,
@"foreground"
,
ac
,
@"autoCancel"
,
nil
];
return
[
NSDictionary
dictionaryWithObjectsAndKeys
:
id
,
@"id"
,
bg
,
@"background"
,
fg
,
@"foreground"
,
ac
,
@"autoCancel"
,
js
,
@"json"
,
nil
];
}
}
/**
/**
...
@@ -229,6 +234,7 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION";
...
@@ -229,6 +234,7 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION";
UILocalNotification
*
notification
=
[
localNotification
object
];
UILocalNotification
*
notification
=
[
localNotification
object
];
NSString
*
id
=
[
notification
.
userInfo
objectForKey
:
@"id"
];
NSString
*
id
=
[
notification
.
userInfo
objectForKey
:
@"id"
];
NSString
*
json
=
[
notification
.
userInfo
objectForKey
:
@"json"
];
NSString
*
callbackType
=
isActive
?
@"foreground"
:
@"background"
;
NSString
*
callbackType
=
isActive
?
@"foreground"
:
@"background"
;
NSString
*
callbackFn
=
[
notification
.
userInfo
objectForKey
:
callbackType
];
NSString
*
callbackFn
=
[
notification
.
userInfo
objectForKey
:
callbackType
];
BOOL
autoCancel
=
[[
notification
.
userInfo
objectForKey
:
@"autoCancel"
]
boolValue
];
BOOL
autoCancel
=
[[
notification
.
userInfo
objectForKey
:
@"autoCancel"
]
boolValue
];
...
@@ -240,7 +246,8 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION";
...
@@ -240,7 +246,8 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION";
if
(
!
[
self
strIsNullOrEmpty
:
callbackFn
])
if
(
!
[
self
strIsNullOrEmpty
:
callbackFn
])
{
{
NSString
*
js
=
[
NSString
stringWithFormat
:
@"setTimeout('%@(
\"
%@
\"
)',0)"
,
callbackFn
,
id
];
NSString
*
params
=
[
NSString
stringWithFormat
:
@"
\"
%@
\"
,
\\
'%@
\\
'"
,
id
,
json
];
NSString
*
js
=
[
NSString
stringWithFormat
:
@"setTimeout('%@(%@)',0)"
,
callbackFn
,
params
];
[
self
.
commandDelegate
evalJs
:
js
];
[
self
.
commandDelegate
evalJs
:
js
];
}
}
...
...
src/wp8/Options.cs
View file @
c05c4e14
...
@@ -75,6 +75,12 @@ namespace De.APPPlant.Cordova.Plugin.LocalNotification
...
@@ -75,6 +75,12 @@ namespace De.APPPlant.Cordova.Plugin.LocalNotification
public
string
Repeat
{
get
;
set
;
}
public
string
Repeat
{
get
;
set
;
}
/// <summary>
/// <summary>
/// Notification specific data
/// </summary>
[
DataMember
(
IsRequired
=
false
,
Name
=
"json"
)]
public
string
JSON
{
get
;
set
;
}
/// <summary>
/// Message-ID
/// Message-ID
/// </summary>
/// </summary>
[
DataMember
(
IsRequired
=
false
,
Name
=
"id"
)]
[
DataMember
(
IsRequired
=
false
,
Name
=
"id"
)]
...
...
www/local-notification.js
View file @
c05c4e14
...
@@ -38,6 +38,7 @@ LocalNotification.prototype = {
...
@@ -38,6 +38,7 @@ LocalNotification.prototype = {
autoCancel
:
false
,
autoCancel
:
false
,
badge
:
0
,
badge
:
0
,
id
:
'0'
,
id
:
'0'
,
json
:
''
,
repeat
:
''
,
repeat
:
''
,
background
:
''
,
background
:
''
,
foreground
:
''
foreground
:
''
...
...
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