package com.kbs.kbsintranett;

import android.app.Application;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Build;

public class KbsApplication extends Application {

    public static final String CHANNEL_ID = "kbs_calendar_channel";
    private static Context instance;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = getApplicationContext();
        createNotificationChannel();
    }

    public static Context getContext() {
        return instance;
    }

    private void createNotificationChannel() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel(
                    CHANNEL_ID,
                    "KBS Kalendervarsler",
                    NotificationManager.IMPORTANCE_HIGH
            );
            channel.setDescription("Varsler for kalenderhendelser");

            NotificationManager manager = getSystemService(NotificationManager.class);
            if (manager != null) {
                manager.createNotificationChannel(channel);
            }
        }
    }
}