Added customisable notification icon for Android
This commit is contained in:
parent
04d5dc581b
commit
cd1fb46dcc
@ -201,7 +201,7 @@ document.addEventListener('deviceready', function () {
|
|||||||
To indicate that the app is executing tasks in background and being paused would disrupt the user, the plug-in has to create a notification while in background - like a download progress bar.
|
To indicate that the app is executing tasks in background and being paused would disrupt the user, the plug-in has to create a notification while in background - like a download progress bar.
|
||||||
|
|
||||||
#### Override defaults
|
#### Override defaults
|
||||||
The title, ticker, text for that notification can be customized as below. Also, by default the app will come to foreground when tapping on the notification. That can be changed by setting resume to false. On Android 5.0+, the color option will set the background color of the notification circle. Also on Android 5.0+, setting isPublic to true will make the full notification show on a secure lockscreen.
|
The title, ticker, text and icon for that notification can be customized as below. Also, by default the app will come to foreground when tapping on the notification. That can be changed by setting resume to false. On Android 5.0+, the color option will set the background color of the notification circle. Also on Android 5.0+, setting isPublic to true will make the full notification show on a secure lockscreen.
|
||||||
|
|
||||||
All of these fields are optional - only override the things you need to.
|
All of these fields are optional - only override the things you need to.
|
||||||
|
|
||||||
@ -210,9 +210,10 @@ cordova.plugins.backgroundMode.setDefaults({
|
|||||||
title: String,
|
title: String,
|
||||||
ticker: String,
|
ticker: String,
|
||||||
text: String,
|
text: String,
|
||||||
|
icon: "icon" // this will look for icon.png in platforms/android/res/drawable
|
||||||
resume: true / false,
|
resume: true / false,
|
||||||
color: "#123456",
|
color: "#123456",
|
||||||
isPublic: true / false
|
isPublic: true / false,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -205,12 +205,12 @@ public class ForegroundService extends Service {
|
|||||||
* The resource ID of the app icon
|
* The resource ID of the app icon
|
||||||
*/
|
*/
|
||||||
private int getIconResId() {
|
private int getIconResId() {
|
||||||
|
JSONObject settings = BackgroundMode.getSettings();
|
||||||
Context context = getApplicationContext();
|
Context context = getApplicationContext();
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
String pkgName = context.getPackageName();
|
String pkgName = context.getPackageName();
|
||||||
|
|
||||||
int resId;
|
int resId = res.getIdentifier(settings.optString("icon", "icon"), "drawable", pkgName);
|
||||||
resId = res.getIdentifier("icon", "drawable", pkgName);
|
|
||||||
|
|
||||||
return resId;
|
return resId;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,8 @@ exports._defaults = {
|
|||||||
resume: true,
|
resume: true,
|
||||||
silent: false,
|
silent: false,
|
||||||
isPublic: false,
|
isPublic: false,
|
||||||
color: ""
|
color: "",
|
||||||
|
icon: "icon"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user