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
afc7f250
Commit
afc7f250
authored
Jan 18, 2014
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the ability to override notifications default properties
parent
92ae360d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
23 deletions
+92
-23
README.md
README.md
+18
-0
local-notification.js
www/local-notification.js
+74
-23
No files found.
README.md
View file @
afc7f250
...
@@ -49,6 +49,7 @@ More informations can be found [here](https://build.phonegap.com/plugins/356).
...
@@ -49,6 +49,7 @@ More informations can be found [here](https://build.phonegap.com/plugins/356).
#### Version 0.7.0 (not yet released)
#### Version 0.7.0 (not yet released)
-
**Note:**
The new way of callback registration will be not compatible with previous versions! See #62
-
**Note:**
The new way of callback registration will be not compatible with previous versions! See #62
-
[
feature:
]
Added new callback registration interface and new callback types.
-
[
feature:
]
Added new callback registration interface and new callback types.
-
[
feature:
]
Added the ability to override notifications default properties.
#### Version 0.7.0beta1 (17.01.2014)
#### Version 0.7.0beta1 (17.01.2014)
-
[
bugfix:
]
App throws an error on iOS if
`message`
is null.
-
[
bugfix:
]
App throws an error on iOS if
`message`
is null.
...
@@ -149,6 +150,18 @@ There are 4 different callback types available. For each of them one listener ca
...
@@ -149,6 +150,18 @@ There are 4 different callback types available. For each of them one listener ca
window
.
plugin
.
notification
.
local
.
on_callback_
=
function
(
id
,
state
,
json
)
{};
window
.
plugin
.
notification
.
local
.
on_callback_
=
function
(
id
,
state
,
json
)
{};
```
```
### getDefaults()
Gives an overview about all available notification properties for the platform and their default values. The function returns an object.
```
javascript
window
.
plugin
.
notification
.
local
.
getDefaults
();
```
### setDefaults ()
Overrides the default properties. The function takes an object as argument.
```
javascript
window
.
plugin
.
notification
.
local
.
setDefaults
(
Object
);
```
## Examples
## Examples
#### Will fire every week on this day, 60 seconds from now
#### Will fire every week on this day, 60 seconds from now
...
@@ -193,6 +206,11 @@ window.plugin.notification.local.onclick = function (id, state, json) {
...
@@ -193,6 +206,11 @@ window.plugin.notification.local.onclick = function (id, state, json) {
}
}
```
```
### Change the default value for autoCancel
```
javascript
window
.
plugin
.
notification
.
local
.
setDefaults
({
autoCancel
:
true
});
```
## Platform specifics
## Platform specifics
### Small and large icons on Android
### Small and large icons on Android
...
...
www/local-notification.js
View file @
afc7f250
...
@@ -20,19 +20,7 @@
...
@@ -20,19 +20,7 @@
*/
*/
var
LocalNotification
=
function
()
{
var
LocalNotification
=
function
()
{
this
.
_deafults
=
{
};
LocalNotification
.
prototype
=
{
/**
* Fügt einen neuen Eintrag zur Registry hinzu.
*
* @param {Object} options
* @return {Number} Die ID der Notification
*/
add
:
function
(
options
)
{
var
defaults
=
{
date
:
new
Date
(),
message
:
''
,
message
:
''
,
title
:
''
,
title
:
''
,
autoCancel
:
false
,
autoCancel
:
false
,
...
@@ -42,6 +30,57 @@ LocalNotification.prototype = {
...
@@ -42,6 +30,57 @@ LocalNotification.prototype = {
json
:
''
,
json
:
''
,
repeat
:
''
repeat
:
''
};
};
};
LocalNotification
.
prototype
=
{
/**
* Gibt alle Standardeinstellungen an.
*
* @return {Object}
*/
getDefaults
:
function
()
{
return
this
.
_deafults
;
},
/**
* Überschreibt die Standardeinstellungen.
*
* @param {Object} defaults
*/
setDefaults
:
function
(
newDefaults
)
{
var
defaults
=
this
.
getDefaults
();
for
(
var
key
in
defaults
)
{
if
(
newDefaults
[
key
]
!==
undefined
)
{
defaults
[
key
]
=
newDefaults
[
key
];
}
}
},
/**
* @private
* Merged die Eigenschaften mit den Standardwerten.
*
* @param {Object} options
* @retrun {Object}
*/
mergeWithDefaults
:
function
(
options
)
{
var
defaults
=
this
.
getDefaults
();
for
(
var
key
in
defaults
)
{
if
(
options
[
key
]
===
undefined
)
{
options
[
key
]
=
defaults
[
key
];
}
}
return
options
;
},
/**
* @private
*/
applyPlatformSpecificOptions
:
function
()
{
var
defaults
=
this
.
_deafults
;
switch
(
device
.
platform
)
{
switch
(
device
.
platform
)
{
case
'Android'
:
case
'Android'
:
...
@@ -55,24 +94,32 @@ LocalNotification.prototype = {
...
@@ -55,24 +94,32 @@ LocalNotification.prototype = {
defaults
.
image
=
null
;
defaults
.
image
=
null
;
defaults
.
wideImage
=
null
;
defaults
.
wideImage
=
null
;
};
};
},
for
(
var
key
in
defaults
)
{
/**
if
(
options
[
key
]
!==
undefined
)
{
* Fügt einen neuen Eintrag zur Registry hinzu.
defaults
[
key
]
=
options
[
key
];
*
}
* @param {Object} options
* @return {Number} Die ID der Notification
*/
add
:
function
(
options
)
{
var
options
=
this
.
mergeWithDefaults
(
options
);
if
(
options
.
id
)
{
options
.
id
=
options
.
id
.
toString
();
}
}
if
(
defaults
.
i
d
)
{
if
(
options
.
date
===
undefine
d
)
{
defaults
.
id
=
defaults
.
id
.
toString
();
options
.
date
=
new
Date
();
}
}
if
(
typeof
default
s
.
date
==
'object'
)
{
if
(
typeof
option
s
.
date
==
'object'
)
{
defaults
.
date
=
Math
.
round
(
default
s
.
date
.
getTime
()
/
1000
);
options
.
date
=
Math
.
round
(
option
s
.
date
.
getTime
()
/
1000
);
}
}
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'add'
,
[
default
s
]);
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'add'
,
[
option
s
]);
return
default
s
.
id
;
return
option
s
.
id
;
},
},
/**
/**
...
@@ -130,4 +177,8 @@ LocalNotification.prototype = {
...
@@ -130,4 +177,8 @@ LocalNotification.prototype = {
var
plugin
=
new
LocalNotification
();
var
plugin
=
new
LocalNotification
();
document
.
addEventListener
(
'deviceready'
,
function
()
{
plugin
.
applyPlatformSpecificOptions
();
},
false
);
module
.
exports
=
plugin
;
module
.
exports
=
plugin
;
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