Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification icon color #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ BackgroundGeolocation.addWatcher(
// The title of the notification mentioned above. Defaults to "Using
// your location".
backgroundTitle: "Tracking You.",


// The color of the notification icon when app is in the background. Defaults to black.
backgroundIconColor: "#000000",

// Whether permissions should be requested from the user automatically,
// if they are not already granted. Defaults to "true".
requestPermissions: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.graphics.Color;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
Expand Down Expand Up @@ -83,6 +84,8 @@ public void onSuccess(Location location) {
}
Notification backgroundNotification = null;
String backgroundMessage = call.getString("backgroundMessage");
int color = Color.parseColor(call.getString("backgroundIconColor"));

if (backgroundMessage != null) {
Notification.Builder builder = new Notification.Builder(getContext())
.setContentTitle(
Expand All @@ -92,6 +95,7 @@ public void onSuccess(Location location) {
)
)
.setContentText(backgroundMessage)
.setColor(color)
.setOngoing(true)
.setPriority(Notification.PRIORITY_HIGH)
.setWhen(System.currentTimeMillis());
Expand Down