Skip to content

Commit

Permalink
prompt request permission
Browse files Browse the repository at this point in the history
  • Loading branch information
sc-nick committed Apr 17, 2024
1 parent 3152740 commit f209eae
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/android/LocalNotification.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.util.Pair;
import android.view.View;

Expand Down Expand Up @@ -90,6 +95,14 @@ public void initialize (CordovaInterface cordova, CordovaWebView webView) {
public void onResume (boolean multitasking) {
super.onResume(multitasking);
deviceready();

Context context = cordova.getActivity().getApplicationContext();
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !alarmManager.canScheduleExactAlarms()) {
Intent intent = new Intent(android.provider.Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM);
intent.setData(Uri.fromParts("package", context.getPackageName(), null));
cordova.getActivity().startActivity(intent);
}
}

/**
Expand Down

0 comments on commit f209eae

Please sign in to comment.