Compare commits
3 Commits
f38b06abed
...
839e167c98
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
839e167c98 | ||
|
|
f40562b68a | ||
|
|
f1830e5f6f |
@@ -474,26 +474,37 @@ class NotifyReceiver : BroadcastReceiver() {
|
||||
return
|
||||
}
|
||||
}
|
||||
val pendingIntent = PendingIntent.getBroadcast(
|
||||
context,
|
||||
requestCode,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
alarmManager.cancel(pendingIntent)
|
||||
Log.i(TAG, "DNP-CANCEL: Notification alarm cancelled: scheduleId=$scheduleId, triggerAt=$triggerAtMillis, requestCode=$requestCode")
|
||||
|
||||
// Verify cancellation by checking if alarm still exists
|
||||
val verifyIntent = PendingIntent.getBroadcast(
|
||||
// CRITICAL: Use FLAG_NO_CREATE to get existing PendingIntent, don't create new one
|
||||
// This matches the pattern used in scheduleExactNotification for proper cancellation
|
||||
val existingPendingIntent = PendingIntent.getBroadcast(
|
||||
context,
|
||||
requestCode,
|
||||
intent,
|
||||
PendingIntent.FLAG_NO_CREATE or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
if (verifyIntent == null) {
|
||||
Log.d(TAG, "DNP-CANCEL: ✅ Cancellation verified - no PendingIntent found for requestCode=$requestCode")
|
||||
|
||||
if (existingPendingIntent != null) {
|
||||
// Cancel both the alarm in AlarmManager AND the PendingIntent itself
|
||||
// This matches the pattern in scheduleExactNotification (lines 311-312)
|
||||
alarmManager.cancel(existingPendingIntent)
|
||||
existingPendingIntent.cancel()
|
||||
Log.i(TAG, "DNP-CANCEL: Notification alarm cancelled: scheduleId=$scheduleId, triggerAt=$triggerAtMillis, requestCode=$requestCode")
|
||||
|
||||
// Verify cancellation by checking if alarm still exists
|
||||
val verifyIntent = PendingIntent.getBroadcast(
|
||||
context,
|
||||
requestCode,
|
||||
intent,
|
||||
PendingIntent.FLAG_NO_CREATE or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
if (verifyIntent == null) {
|
||||
Log.d(TAG, "DNP-CANCEL: ✅ Cancellation verified - no PendingIntent found for requestCode=$requestCode")
|
||||
} else {
|
||||
Log.w(TAG, "DNP-CANCEL: ⚠️ Cancellation may have failed - PendingIntent still exists for requestCode=$requestCode")
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "DNP-CANCEL: ⚠️ Cancellation may have failed - PendingIntent still exists for requestCode=$requestCode")
|
||||
Log.d(TAG, "DNP-CANCEL: No existing PendingIntent found to cancel: scheduleId=$scheduleId, requestCode=$requestCode")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -346,6 +346,60 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Load configuration status (plugin settings and native fetcher)
|
||||
function loadConfigurationStatus() {
|
||||
console.log('[Config Check] Checking configuration status...');
|
||||
const configStatus = document.getElementById('configStatus');
|
||||
const fetcherStatus = document.getElementById('fetcherStatus');
|
||||
|
||||
if (!window.DailyNotification) {
|
||||
console.warn('[Config Check] DailyNotification plugin not available');
|
||||
configStatus.innerHTML = '❌ Plugin unavailable';
|
||||
fetcherStatus.innerHTML = '❌ Plugin unavailable';
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if plugin settings are configured
|
||||
// Plugin settings are stored internally, so we check by trying to get status
|
||||
// For now, we'll check if native fetcher config exists as a proxy
|
||||
// TODO: Add explicit plugin settings check method
|
||||
window.DailyNotification.getConfig({ key: 'native_fetcher_config' })
|
||||
.then(result => {
|
||||
console.log('[Config Check] Native fetcher config result:', JSON.stringify(result));
|
||||
if (result && result.config && result.config.configValue) {
|
||||
try {
|
||||
const configValue = JSON.parse(result.config.configValue);
|
||||
if (configValue.apiBaseUrl && configValue.apiBaseUrl.length > 0) {
|
||||
console.log('[Config Check] ✅ Native fetcher is configured');
|
||||
fetcherStatus.innerHTML = '✅ Configured';
|
||||
} else {
|
||||
console.log('[Config Check] ⚠️ Native fetcher config exists but is empty');
|
||||
fetcherStatus.innerHTML = '❌ Not configured';
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Config Check] Failed to parse config value:', e);
|
||||
fetcherStatus.innerHTML = '❌ Error';
|
||||
}
|
||||
} else {
|
||||
console.log('[Config Check] ❌ Native fetcher config not found');
|
||||
fetcherStatus.innerHTML = '❌ Not configured';
|
||||
}
|
||||
|
||||
// For plugin settings, we assume configured if native fetcher is configured
|
||||
// This is a heuristic - in production, add explicit check
|
||||
if (fetcherStatus.innerHTML.includes('✅')) {
|
||||
configStatus.innerHTML = '✅ Configured';
|
||||
} else {
|
||||
configStatus.innerHTML = '❌ Not configured';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('[Config Check] Failed to check configuration:', error);
|
||||
configStatus.innerHTML = '❌ Error';
|
||||
fetcherStatus.innerHTML = '❌ Error';
|
||||
});
|
||||
}
|
||||
|
||||
function loadChannelStatus() {
|
||||
const channelStatus = document.getElementById('channelStatus');
|
||||
|
||||
@@ -568,11 +622,12 @@
|
||||
// Load plugin status automatically on page load
|
||||
window.addEventListener('load', () => {
|
||||
console.log('Page loaded, loading plugin status...');
|
||||
// Small delay to ensure Capacitor is ready
|
||||
setTimeout(() => {
|
||||
loadPluginStatus();
|
||||
loadPermissionStatus();
|
||||
loadChannelStatus();
|
||||
// Small delay to ensure Capacitor is ready
|
||||
setTimeout(() => {
|
||||
loadPluginStatus();
|
||||
loadPermissionStatus();
|
||||
loadChannelStatus();
|
||||
loadConfigurationStatus();
|
||||
|
||||
// Initialize last known next notification time
|
||||
if (window.DailyNotification) {
|
||||
@@ -600,6 +655,7 @@
|
||||
loadPluginStatus();
|
||||
loadPermissionStatus();
|
||||
loadChannelStatus();
|
||||
loadConfigurationStatus();
|
||||
|
||||
// Also check for recent notifications that might have been missed
|
||||
if (window.DailyNotification) {
|
||||
|
||||
@@ -381,7 +381,8 @@
|
||||
fetcherStatus.innerHTML = '❌ Error';
|
||||
}
|
||||
} else {
|
||||
console.log('[Config Check] ❌ Native fetcher config not found');
|
||||
console.log('[Config Check] ❌ Native fetcher config not found in database');
|
||||
console.log('[Config Check] This may be normal after app uninstall/reinstall (database wiped)');
|
||||
fetcherStatus.innerHTML = '❌ Not configured';
|
||||
}
|
||||
|
||||
@@ -395,8 +396,15 @@
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('[Config Check] Failed to check configuration:', error);
|
||||
configStatus.innerHTML = '❌ Error';
|
||||
fetcherStatus.innerHTML = '❌ Error';
|
||||
// Don't show error if database might not be ready yet (recovery in progress)
|
||||
if (error.message && error.message.includes('database')) {
|
||||
console.log('[Config Check] Database may not be ready yet, will retry...');
|
||||
fetcherStatus.innerHTML = '⏳ Checking...';
|
||||
configStatus.innerHTML = '⏳ Checking...';
|
||||
} else {
|
||||
configStatus.innerHTML = '❌ Error';
|
||||
fetcherStatus.innerHTML = '❌ Error';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -650,8 +658,15 @@
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
if (!document.hidden) {
|
||||
console.log('[Visibility] App became visible, refreshing UI status...');
|
||||
// Small delay to allow recovery to complete
|
||||
// Longer delay to allow recovery to complete (force-stop recovery can take a few seconds)
|
||||
// Also refresh immediately, then again after delay to catch any late recovery
|
||||
loadPluginStatus();
|
||||
loadPermissionStatus();
|
||||
loadChannelStatus();
|
||||
loadConfigurationStatus();
|
||||
|
||||
setTimeout(() => {
|
||||
console.log('[Visibility] Delayed refresh after recovery period...');
|
||||
loadPluginStatus();
|
||||
loadPermissionStatus();
|
||||
loadChannelStatus();
|
||||
@@ -692,7 +707,7 @@
|
||||
console.error('[Visibility] Failed to get notification status:', error);
|
||||
});
|
||||
}
|
||||
}, 1000); // Wait 1 second for recovery to complete
|
||||
}, 3000); // Wait 3 seconds for recovery to complete (force-stop recovery can take time)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user