Skip to content

Class Notification

PavelTychinin edited this page Sep 17, 2021 · 4 revisions

Notification class is used for working with the notifications and storing its data.

Referenced from: NotificationListener.

Public methods

Function getId

public int getId()

Function returns the notification's identifier.

Function getTitle

public String getTitle()

Function returns the notification's title.

Function getContent

public String getContent()

Function returns the notification's content description.

Function getImageId

public String getImageId()

Function returns the notification's image id, which could be used for getting Image using ResourceManager.

Usage example

public class MyApp extends Application {
    public static LocationManager mLocationManager = null;
    public static NotificationManager mNotificationManager = null;

...

    @Override
    public void onCreate() {
        super.onCreate();
        NavigineSdk.setUserHash("0000-0000-0000-0000");
        NavigineSdk.setServer("https://api.navigine.com");
        mNavigineSdk = NavigineSdk.getInstance();
        mLocationManager = mNavigineSdk.getLocationManager();
        mLocationManager.setLocationId(12345);
        mNotificationManager = mNavigineSdk.getNotificationManager(mLocationManager);

        mNotificationManager.addNotificationListener(new NotificationListener() {
            @Override
            public void onNotificationLoaded(Notification notification) {
                Log.d("Notification", "onNotificationReceived: " + notification.getTitle());
            }

            @Override
            public void onNotificationFailed(Error error) {
                Log.d("Notification", "onNotificationFailed: " + error.getMessage());
            }
        });

...

Notifications in background

  • Request ACCESS_BACKGROUND_LOCATION and FOREGROUND_SERVICE permissions
  • Add foreground service to your app
  • Call Navigine.setMode(Navigine.Mode.BACKGROUND); when your app goes to background
  • Call Navigine.setMode(Navigine.Mode.NORMAL); when your app goes to foreground

P.S Check NavigineDemo how to do it correct

Clone this wiki locally