Is LocalNotification Id suppose to be displayed in ToastBar?
I created a Local notification:
LocalNotification ln = new LocalNotification();
ln.setId("geofence entered");
ln.setAlertTitle("Welcome");
ln.setAlertBody("Please proceed to the building");
Display.getInstance().scheduleLocalNotification(ln,
System.currentTimeMillis() + 1000, LocalNotification.REPEAT_NONE);
It fires properly and shows me a notification with correct Title and Body. However, if I click on it, when it opens the app - the Id
"geofence entered" is displayed in ToastBar
. If I remove .setId("geofence entered")
, the notification is not shown and I get an error:
2021-07-13 17:15:40.009 21809-21809/io.jarvisapp.app E/Codename One: background location error
java.lang.IllegalArgumentException: Notification ID must be set
at com.codename1.ui.Display.scheduleLocalNotification(Display.java:4804)
at io.jarvisapp.app.geofence.GeofenceListenerImpl.onEntered(GeofenceListenerImpl.java:131)
where line 131 is Display.getInstance().scheduleLocalNotification(ln, System.currentTimeMillis() + 1000, LocalNotification.REPEAT_NONE);
How can I not display the id in ToastBar? Thank you in advance.
The piece of code that was causing the issue was found, thanks to @Shai comment about the callback code.
I completely forgot that I implemented LocalNotificationCallback
with the following method in my main class:
@Override
public void localNotificationReceived(String notificationId) {
GeneralUtil.showToastBarMessage(notificationId,3000,0);
}