From f209eae440c6104b5d114bffad7241cc43d9463e Mon Sep 17 00:00:00 2001 From: sc-nick Date: Wed, 17 Apr 2024 14:49:28 +0300 Subject: [PATCH] prompt request permission --- src/android/LocalNotification.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/android/LocalNotification.java b/src/android/LocalNotification.java index 7b92a178b..725f339e1 100644 --- a/src/android/LocalNotification.java +++ b/src/android/LocalNotification.java @@ -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; @@ -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); + } } /**