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
b03bdf08
Commit
b03bdf08
authored
Jan 10, 2014
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Android specific property `smallImage`
parent
7ae2981b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
5 deletions
+28
-5
README.md
README.md
+4
-3
Options.java
src/android/Options.java
+17
-1
Receiver.java
src/android/Receiver.java
+6
-1
local-notification.js
www/local-notification.js
+1
-0
No files found.
README.md
View file @
b03bdf08
...
@@ -58,6 +58,7 @@ More informations can be found [here](https://build.phonegap.com/plugins/356).
...
@@ -58,6 +58,7 @@ More informations can be found [here](https://build.phonegap.com/plugins/356).
-
[
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.
-
[
feature:
]
Added
`json`
property to pass custom data through the notification.
-
[
enhancement:
]
Added Android specific property
`smallImage`
.
#### Version 0.6.3 (12.12.2013)
#### Version 0.6.3 (12.12.2013)
-
[
bugfix:
]
Black screen on Android.
-
[
bugfix:
]
Black screen on Android.
...
@@ -186,8 +187,8 @@ function foreground (id, json) {
...
@@ -186,8 +187,8 @@ function foreground (id, json) {
## Platform specifics
## Platform specifics
###
Notification icon
on Android
###
Small and large icons
on Android
By default all notifications will display the app icon. But an specific icon can be defined through the
`icon`
property
.
By default all notifications will display the app icon. But an specific icon can be defined through the
`icon`
and
`smallIcon`
properties
.
```
javascript
```
javascript
/**
/**
* Displays the <package.name>.R.drawable.ic_launcher icon
* Displays the <package.name>.R.drawable.ic_launcher icon
...
@@ -197,7 +198,7 @@ window.plugin.notification.local.add({ icon: 'ic_launcher' });
...
@@ -197,7 +198,7 @@ window.plugin.notification.local.add({ icon: 'ic_launcher' });
/**
/**
* Displays the android.R.drawable.ic_dialog_email icon
* Displays the android.R.drawable.ic_dialog_email icon
*/
*/
window
.
plugin
.
notification
.
local
.
add
({
i
con
:
'ic_dialog_email'
});
window
.
plugin
.
notification
.
local
.
add
({
smallI
con
:
'ic_dialog_email'
});
```
```
### Notification sound on Android
### Notification sound on Android
...
...
src/android/Options.java
View file @
b03bdf08
...
@@ -147,7 +147,7 @@ public class Options {
...
@@ -147,7 +147,7 @@ public class Options {
}
}
/**
/**
* Gibt den
Pfad zum Icon der Notification
an.
* Gibt den
ID Code des Bildes
an.
*/
*/
public
int
getIcon
()
{
public
int
getIcon
()
{
int
icon
=
0
;
int
icon
=
0
;
...
@@ -167,6 +167,22 @@ public class Options {
...
@@ -167,6 +167,22 @@ public class Options {
}
}
/**
/**
* Gibt den ID Code des kleinen Bildes an.
*/
public
int
getSmallIcon
()
{
int
resId
=
0
;
String
iconName
=
options
.
optString
(
"smallIcon"
,
""
);
resId
=
getIconValue
(
packageName
,
iconName
);
if
(
resId
==
0
)
{
resId
=
getIconValue
(
"android"
,
iconName
);
}
return
options
.
optInt
(
"smallIcon"
,
resId
);
}
/**
* Gibt den Pfad zur Callback-Funktion der Notification an.
* Gibt den Pfad zur Callback-Funktion der Notification an.
*/
*/
public
String
getForeground
()
{
public
String
getForeground
()
{
...
...
src/android/Receiver.java
View file @
b03bdf08
...
@@ -36,6 +36,8 @@ import android.app.PendingIntent;
...
@@ -36,6 +36,8 @@ import android.app.PendingIntent;
import
android.content.BroadcastReceiver
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
...
@@ -118,12 +120,15 @@ public class Receiver extends BroadcastReceiver {
...
@@ -118,12 +120,15 @@ public class Receiver extends BroadcastReceiver {
* Erstellt die Notification.
* Erstellt die Notification.
*/
*/
private
Builder
buildNotification
()
{
private
Builder
buildNotification
()
{
Bitmap
icon
=
BitmapFactory
.
decodeResource
(
context
.
getResources
(),
options
.
getIcon
());
Builder
notification
=
new
Notification
.
Builder
(
context
)
Builder
notification
=
new
Notification
.
Builder
(
context
)
.
setContentTitle
(
options
.
getTitle
())
.
setContentTitle
(
options
.
getTitle
())
.
setContentText
(
options
.
getMessage
())
.
setContentText
(
options
.
getMessage
())
.
setNumber
(
options
.
getBadge
())
.
setNumber
(
options
.
getBadge
())
.
setTicker
(
options
.
getTitle
())
.
setTicker
(
options
.
getTitle
())
.
setSmallIcon
(
options
.
getIcon
())
.
setSmallIcon
(
options
.
getSmallIcon
())
.
setLargeIcon
(
icon
)
.
setSound
(
options
.
getSound
())
.
setSound
(
options
.
getSound
())
.
setAutoCancel
(
options
.
getAutoCancel
());
.
setAutoCancel
(
options
.
getAutoCancel
());
...
...
www/local-notification.js
View file @
b03bdf08
...
@@ -47,6 +47,7 @@ LocalNotification.prototype = {
...
@@ -47,6 +47,7 @@ LocalNotification.prototype = {
switch
(
device
.
platform
)
{
switch
(
device
.
platform
)
{
case
'Android'
:
case
'Android'
:
defaults
.
icon
=
'icon'
;
defaults
.
icon
=
'icon'
;
defaults
.
smallIcon
=
null
;
defaults
.
sound
=
'TYPE_NOTIFICATION'
;
break
;
defaults
.
sound
=
'TYPE_NOTIFICATION'
;
break
;
case
'iOS'
:
case
'iOS'
:
defaults
.
sound
=
''
;
break
;
defaults
.
sound
=
''
;
break
;
...
...
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