Android-Proximity-SDK icon indicating copy to clipboard operation
Android-Proximity-SDK copied to clipboard

[Question] Can I update the notification for the background monitoring?

Open ldimitroff opened this issue 7 years ago • 3 comments

Is there a way to update the notification for background? Either using the channel id and do it myself or getting the notification by the SDK and tell it to update, text and icon?

Thanks

ldimitroff avatar May 09 '18 12:05 ldimitroff

Hey @ldimitroff

According to Android's official documentation:

To update this notification after you've issued it, call NotificationManagerCompat.notify() again, passing it a notification with the same ID you used previously. If the previous notification has been dismissed, a new notification is created instead.

So I assume this is how it should be achieved. More info here.

Edit: Oh, I just looked through our code, and realised we are using our own notification id. This could possibly be changed to let the user choose a notification id (for updating it later), but we need to make some tests with this. Can you share your use-case with me? Why it is important for you to change text/icon of the static "scan in progress" notification?

Cheers, Paweł

pawelDylag avatar May 10 '18 07:05 pawelDylag

@pawelDylag my use case is that I want to just show only one notification in the app. If that's not possible, the "scan in progress" should change to a more descriptive text. I'm scanning beacons for moving users from a "pre tour" state to a "on tour" status, and I want to show something like "Your tour will start soon" and "Tour in progress" static notification, not just a generic notification.

ldimitroff avatar May 10 '18 14:05 ldimitroff

@ldimitroff thanks for the explanation. Your use case is pretty valid, and I can think about achieving that behaviour with using our foreground service.

Although I think that if you need customisation, you can always create your own foreground service with a notification, and make the ProximityObserver to run inside it (without calling .withScannerInForegroundService(), which won't wrap it in a foreground service). In such way you will have full control over the lifecycle of your service, as well as notification updates.

Let me know what you think about this :)

pawelDylag avatar May 10 '18 14:05 pawelDylag