diff --git a/CHANGELOG.md b/CHANGELOG.md index a66ef3a..3ab35de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - __Changes__ - Deprecate event callbacks - Notification not visible anymore on lock screen + - Remove ticker property on Android - Remove unexpected back button handler - Remove support for wp8 platform diff --git a/README.md b/README.md index 42c9dd4..ab4d226 100644 --- a/README.md +++ b/README.md @@ -98,11 +98,13 @@ More informations can be found [here][PGB_plugin]. - __Changes__ - Deprecate event callbacks - Notification not visible anymore on lock screen + - Remove ticker property on Android - Remove unexpected back button handler - Remove support for wp8 platform #### Further informations - See [CHANGELOG.md][changelog] to get the full changelog for the plugin. +- Master branch contains experimental support for the windows platform. See #222 #### Known issues - README is out of date !!! diff --git a/src/android/ForegroundService.java b/src/android/ForegroundService.java index 0c37b73..f77dfb2 100644 --- a/src/android/ForegroundService.java +++ b/src/android/ForegroundService.java @@ -47,6 +47,17 @@ public class ForegroundService extends Service { // Fixed ID for the 'foreground' notification public static final int NOTIFICATION_ID = -574543954; + // Default title of the background notification + private static final String NOTIFICATION_TITLE = + "App is running in background"; + + // Default text of the background notification + private static final String NOTIFICATION_TEXT = + "Doing heavy tasks."; + + // Default icon of the background notification + private static final String NOTIFICATION_ICON = "icon"; + // Binder given to clients private final IBinder mBinder = new ForegroundBinder(); @@ -141,7 +152,8 @@ public class ForegroundService extends Service { * @param settings The config settings */ private Notification makeNotification(JSONObject settings) { - String text = settings.optString("text", ""); + String title = settings.optString("title", NOTIFICATION_TITLE); + String text = settings.optString("text", NOTIFICATION_TEXT); boolean bigText = settings.optBoolean("bigText", false); Context context = getApplicationContext(); @@ -150,9 +162,8 @@ public class ForegroundService extends Service { .getLaunchIntentForPackage(pkgName); Notification.Builder notification = new Notification.Builder(context) - .setContentTitle(settings.optString("title", "")) + .setContentTitle(title) .setContentText(text) - .setTicker(settings.optString("ticker", "")) .setOngoing(true) .setPriority(Notification.PRIORITY_MIN) .setSmallIcon(getIconResId(settings)); @@ -203,7 +214,7 @@ public class ForegroundService extends Service { Context context = getApplicationContext(); Resources res = context.getResources(); String pkgName = context.getPackageName(); - String icon = settings.optString("icon", "icon"); + String icon = settings.optString("icon", NOTIFICATION_ICON); // cordova-android 6 uses mipmaps int resId = getIconResId(res, icon, "mipmap", pkgName);