@ -1118,6 +1118,26 @@ public class DailyNotificationPlugin extends Plugin {
}
}
/ * *
* Request notification permissions ( alias for requestNotificationPermissions )
*
* @param call Plugin call
* /
@PluginMethod
public void requestPermissions ( PluginCall call ) {
Log . d ( TAG , "DEBUG: requestPermissions method called" ) ;
Log . d ( TAG , "DEBUG: Method call received from JavaScript" ) ;
Log . d ( TAG , "DEBUG: Delegating to requestNotificationPermissions" ) ;
try {
// Delegate to the main permission request method
requestNotificationPermissions ( call ) ;
} catch ( Exception e ) {
Log . e ( TAG , "DEBUG: Error in requestPermissions delegation" , e ) ;
call . reject ( "Error in requestPermissions: " + e . getMessage ( ) ) ;
}
}
/ * *
* Request notification permissions
*
@ -1126,18 +1146,25 @@ public class DailyNotificationPlugin extends Plugin {
@PluginMethod
public void requestNotificationPermissions ( PluginCall call ) {
try {
Log . d ( TAG , "DEBUG: requestNotificationPermissions method called" ) ;
Log . d ( TAG , "DEBUG: Android SDK version: " + Build . VERSION . SDK_INT ) ;
Log . d ( TAG , "DEBUG: TIRAMISU version: " + Build . VERSION_CODES . TIRAMISU ) ;
Log . d ( TAG , "Requesting notification permissions" ) ;
if ( Build . VERSION . SDK_INT > = Build . VERSION_CODES . TIRAMISU ) {
Log . d ( TAG , "DEBUG: Android 13+ detected, requesting POST_NOTIFICATIONS permission" ) ;
// Request POST_NOTIFICATIONS permission for Android 13+
requestPermissionForAlias ( "notifications" , call , "notificati onPermissions" ) ;
requestPermissionForAlias ( "notifications" , call , "onPermissionRe sult " ) ;
} else {
Log . d ( TAG , "DEBUG: Pre-Android 13, checking notification manager" ) ;
// For older versions, check if notifications are enabled
boolean enabled = NotificationManagerCompat . from ( getContext ( ) ) . areNotificationsEnabled ( ) ;
Log . d ( TAG , "DEBUG: Notifications enabled: " + enabled ) ;
if ( enabled ) {
Log . i ( TAG , "Notifications already enabled" ) ;
call . resolve ( ) ;
} else {
Log . d ( TAG , "DEBUG: Opening notification settings" ) ;
// Open notification settings
openNotificationSettings ( ) ;
call . resolve ( ) ;
@ -1145,6 +1172,7 @@ public class DailyNotificationPlugin extends Plugin {
}
} catch ( Exception e ) {
Log . e ( TAG , "DEBUG: Exception in requestNotificationPermissions" , e ) ;
Log . e ( TAG , "Error requesting notification permissions" , e ) ;
call . reject ( "Error requesting permissions: " + e . getMessage ( ) ) ;
}
@ -1156,14 +1184,17 @@ public class DailyNotificationPlugin extends Plugin {
* @param call Plugin call containing permission result
* /
@PermissionCallback
private void notificati onPermissions( PluginCall call ) {
private void onPermissionRe sult ( PluginCall call ) {
try {
Log . d ( TAG , "Notification permission callback received" ) ;
Log . d ( TAG , "DEBUG: onPermissionResult callback received" ) ;
Log . d ( TAG , "Permission callback received" ) ;
// Check if POST_NOTIFICATIONS permission was granted
boolean permissionGranted = getContext ( ) . checkSelfPermission ( Manifest . permission . POST_NOTIFICATIONS )
= = PackageManager . PERMISSION_GRANTED ;
Log . d ( TAG , "DEBUG: Permission granted: " + permissionGranted ) ;
if ( permissionGranted ) {
Log . i ( TAG , "Notification permission granted" ) ;
call . resolve ( ) ;
@ -1173,11 +1204,31 @@ public class DailyNotificationPlugin extends Plugin {
}
} catch ( Exception e ) {
Log . e ( TAG , "Error in notification permission callback" , e ) ;
Log . e ( TAG , "DEBUG: Exception in onPermissionResult callback" , e ) ;
Log . e ( TAG , "Error in permission callback" , e ) ;
call . reject ( "Error processing permission result: " + e . getMessage ( ) ) ;
}
}
/ * *
* Check current permission status ( alias for checkPermissionStatus )
*
* @param call Plugin call
* /
@PluginMethod
public void checkPermissions ( PluginCall call ) {
Log . d ( TAG , "DEBUG: checkPermissions method called (alias)" ) ;
Log . d ( TAG , "DEBUG: Delegating to checkPermissionStatus" ) ;
try {
// Delegate to the main permission check method
checkPermissionStatus ( call ) ;
} catch ( Exception e ) {
Log . e ( TAG , "DEBUG: Error in checkPermissions delegation" , e ) ;
call . reject ( "Error in checkPermissions: " + e . getMessage ( ) ) ;
}
}
/ * *
* Check current permission status
*
@ -1193,6 +1244,7 @@ public class DailyNotificationPlugin extends Plugin {
// Check notification permissions
boolean notificationsEnabled = areNotificationsEnabled ( ) ;
result . put ( "notificationsEnabled" , notificationsEnabled ) ;
result . put ( "notifications" , notificationsEnabled ? "granted" : "denied" ) ;
// Check exact alarm permissions (Android 12+)
boolean exactAlarmEnabled = true ;