feat(ios): enhance permission UI feedback with detailed logging

Enhanced permission request/check UI with better feedback:

Permission UI Enhancements:
- Added detailed console logging for permission operations
- Enhanced status display with emoji indicators
- Shows detailed permission results (status, granted, alert, badge, sound)
- Better error messages with full error details
- Visual feedback with color-coded status backgrounds

Console Logging:
- Logs when permission functions are called
- Logs plugin availability status
- Logs permission request/check results
- Logs errors with full details

Fixes:
- Permission visibility: Users can now see detailed permission status
- Error debugging: Full error messages help diagnose issues
- User feedback: Clear visual and text feedback for permission state

Result: Permission operations now provide comprehensive feedback in both UI and console
This commit is contained in:
Matthew Raymer
2025-11-11 22:25:52 -08:00
parent 4412838c74
commit 328311281c

View File

@@ -1,8 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="viewport"
content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"> <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0"> <meta http-equiv="Expires" content="0">
@@ -16,15 +18,18 @@
min-height: 100vh; min-height: 100vh;
color: white; color: white;
} }
.container { .container {
max-width: 600px; max-width: 600px;
margin: 0 auto; margin: 0 auto;
text-align: center; text-align: center;
} }
h1 { h1 {
margin-bottom: 30px; margin-bottom: 30px;
font-size: 2.5em; font-size: 2.5em;
} }
.button { .button {
background: rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.2);
border: 2px solid rgba(255, 255, 255, 0.3); border: 2px solid rgba(255, 255, 255, 0.3);
@@ -36,10 +41,12 @@
font-size: 16px; font-size: 16px;
transition: all 0.3s ease; transition: all 0.3s ease;
} }
.button:hover { .button:hover {
background: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.3);
transform: translateY(-2px); transform: translateY(-2px);
} }
.status { .status {
margin-top: 30px; margin-top: 30px;
padding: 20px; padding: 20px;
@@ -49,15 +56,12 @@
} }
</style> </style>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<!-- Immediate visibility test - should appear even if JS fails --> <h1>🔔 DailyNotification Plugin Test</h1>
<div style="background: red; color: white; padding: 20px; margin-bottom: 20px; font-size: 24px; font-weight: bold; text-align: center;"> <p>Test the DailyNotification plugin functionality</p>
✅ HTML IS LOADING - If you see this, the WebView is working! <p style="font-size: 12px; opacity: 0.8;">Build: 2025-10-14 05:00:00 UTC</p>
</div>
<h1>🔔 DailyNotification Plugin Test</h1>
<p>Test the DailyNotification plugin functionality</p>
<p style="font-size: 12px; opacity: 0.8;">Build: 2025-10-14 05:00:00 UTC</p>
<button class="button" onclick="testPlugin()">Test Plugin</button> <button class="button" onclick="testPlugin()">Test Plugin</button>
<button class="button" onclick="configurePlugin()">Configure Plugin</button> <button class="button" onclick="configurePlugin()">Configure Plugin</button>
@@ -88,7 +92,7 @@
console.log('JavaScript is working!'); console.log('JavaScript is working!');
// Show immediate feedback that HTML is loading // Show immediate feedback that HTML is loading
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function () {
console.log('DOM Content Loaded!'); console.log('DOM Content Loaded!');
const body = document.body; const body = document.body;
if (body) { if (body) {
@@ -144,25 +148,25 @@
maxNotificationsPerDay: 3, maxNotificationsPerDay: 3,
retentionDays: 7 retentionDays: 7
}) })
.then(() => { .then(() => {
console.log('Plugin settings configured, now configuring native fetcher...'); console.log('Plugin settings configured, now configuring native fetcher...');
// Configure native fetcher with demo credentials // Configure native fetcher with demo credentials
// Note: DemoNativeFetcher uses hardcoded mock data, so this is optional // Note: DemoNativeFetcher uses hardcoded mock data, so this is optional
// but demonstrates the API. In production, this would be real credentials. // but demonstrates the API. In production, this would be real credentials.
return window.DailyNotification.configureNativeFetcher({ return window.DailyNotification.configureNativeFetcher({
apiBaseUrl: 'http://10.0.2.2:3000', // Android emulator → host localhost apiBaseUrl: 'http://10.0.2.2:3000', // Android emulator → host localhost
activeDid: 'did:ethr:0xDEMO1234567890', // Demo DID activeDid: 'did:ethr:0xDEMO1234567890', // Demo DID
jwtSecret: 'demo-jwt-secret-for-development-testing' jwtSecret: 'demo-jwt-secret-for-development-testing'
});
})
.then(() => {
status.innerHTML = 'Plugin configured successfully!<br>✅ Plugin settings<br>✅ Native fetcher (optional for demo)';
status.style.background = 'rgba(0, 255, 0, 0.3)'; // Green background
})
.catch(error => {
status.innerHTML = `Configuration failed: ${error.message}`;
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
}); });
})
.then(() => {
status.innerHTML = 'Plugin configured successfully!<br>✅ Plugin settings<br>✅ Native fetcher (optional for demo)';
status.style.background = 'rgba(0, 255, 0, 0.3)'; // Green background
})
.catch(error => {
status.innerHTML = `Configuration failed: ${error.message}`;
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
});
} catch (error) { } catch (error) {
status.innerHTML = `Configuration failed: ${error.message}`; status.innerHTML = `Configuration failed: ${error.message}`;
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
@@ -228,9 +232,9 @@
const notificationTime = new Date(now.getTime() + 600000); // 10 minutes from now const notificationTime = new Date(now.getTime() + 600000); // 10 minutes from now
const prefetchTime = new Date(now.getTime() + 300000); // 5 minutes from now const prefetchTime = new Date(now.getTime() + 300000); // 5 minutes from now
const notificationTimeString = notificationTime.getHours().toString().padStart(2, '0') + ':' + const notificationTimeString = notificationTime.getHours().toString().padStart(2, '0') + ':' +
notificationTime.getMinutes().toString().padStart(2, '0'); notificationTime.getMinutes().toString().padStart(2, '0');
const prefetchTimeString = prefetchTime.getHours().toString().padStart(2, '0') + ':' + const prefetchTimeString = prefetchTime.getHours().toString().padStart(2, '0') + ':' +
prefetchTime.getMinutes().toString().padStart(2, '0'); prefetchTime.getMinutes().toString().padStart(2, '0');
window.DailyNotification.scheduleDailyNotification({ window.DailyNotification.scheduleDailyNotification({
time: notificationTimeString, time: notificationTimeString,
@@ -239,18 +243,18 @@
sound: true, sound: true,
priority: 'high' priority: 'high'
}) })
.then(() => { .then(() => {
const prefetchTimeReadable = prefetchTime.toLocaleTimeString(); const prefetchTimeReadable = prefetchTime.toLocaleTimeString();
const notificationTimeReadable = notificationTime.toLocaleTimeString(); const notificationTimeReadable = notificationTime.toLocaleTimeString();
status.innerHTML = '✅ Notification scheduled!<br>' + status.innerHTML = '✅ Notification scheduled!<br>' +
'📥 Prefetch: ' + prefetchTimeReadable + ' (' + prefetchTimeString + ')<br>' + '📥 Prefetch: ' + prefetchTimeReadable + ' (' + prefetchTimeString + ')<br>' +
'🔔 Notification: ' + notificationTimeReadable + ' (' + notificationTimeString + ')'; '🔔 Notification: ' + notificationTimeReadable + ' (' + notificationTimeString + ')';
status.style.background = 'rgba(0, 255, 0, 0.3)'; // Green background status.style.background = 'rgba(0, 255, 0, 0.3)'; // Green background
}) })
.catch(error => { .catch(error => {
status.innerHTML = `Notification failed: ${error.message}`; status.innerHTML = `Notification failed: ${error.message}`;
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
}); });
} catch (error) { } catch (error) {
status.innerHTML = `Notification test failed: ${error.message}`; status.innerHTML = `Notification test failed: ${error.message}`;
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
@@ -275,9 +279,9 @@
const notificationTime = new Date(now.getTime() + 600000); // 10 minutes from now const notificationTime = new Date(now.getTime() + 600000); // 10 minutes from now
const prefetchTime = new Date(now.getTime() + 300000); // 5 minutes from now const prefetchTime = new Date(now.getTime() + 300000); // 5 minutes from now
const notificationTimeString = notificationTime.getHours().toString().padStart(2, '0') + ':' + const notificationTimeString = notificationTime.getHours().toString().padStart(2, '0') + ':' +
notificationTime.getMinutes().toString().padStart(2, '0'); notificationTime.getMinutes().toString().padStart(2, '0');
const prefetchTimeString = prefetchTime.getHours().toString().padStart(2, '0') + ':' + const prefetchTimeString = prefetchTime.getHours().toString().padStart(2, '0') + ':' +
prefetchTime.getMinutes().toString().padStart(2, '0'); prefetchTime.getMinutes().toString().padStart(2, '0');
window.DailyNotification.scheduleDailyNotification({ window.DailyNotification.scheduleDailyNotification({
time: notificationTimeString, time: notificationTimeString,
@@ -286,18 +290,18 @@
sound: true, sound: true,
priority: 'default' priority: 'default'
}) })
.then(() => { .then(() => {
const prefetchTimeReadable = prefetchTime.toLocaleTimeString(); const prefetchTimeReadable = prefetchTime.toLocaleTimeString();
const notificationTimeReadable = notificationTime.toLocaleTimeString(); const notificationTimeReadable = notificationTime.toLocaleTimeString();
status.innerHTML = '✅ Notification scheduled!<br>' + status.innerHTML = '✅ Notification scheduled!<br>' +
'📥 Prefetch: ' + prefetchTimeReadable + ' (' + prefetchTimeString + ')<br>' + '📥 Prefetch: ' + prefetchTimeReadable + ' (' + prefetchTimeString + ')<br>' +
'🔔 Notification: ' + notificationTimeReadable + ' (' + notificationTimeString + ')'; '🔔 Notification: ' + notificationTimeReadable + ' (' + notificationTimeString + ')';
status.style.background = 'rgba(0, 255, 0, 0.3)'; // Green background status.style.background = 'rgba(0, 255, 0, 0.3)'; // Green background
}) })
.catch(error => { .catch(error => {
status.innerHTML = `Scheduling failed: ${error.message}`; status.innerHTML = `Scheduling failed: ${error.message}`;
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
}); });
} catch (error) { } catch (error) {
status.innerHTML = `Scheduling test failed: ${error.message}`; status.innerHTML = `Scheduling test failed: ${error.message}`;
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
@@ -321,7 +325,7 @@
const now = new Date(); const now = new Date();
const reminderTime = new Date(now.getTime() + 10000); // 10 seconds from now const reminderTime = new Date(now.getTime() + 10000); // 10 seconds from now
const timeString = reminderTime.getHours().toString().padStart(2, '0') + ':' + const timeString = reminderTime.getHours().toString().padStart(2, '0') + ':' +
reminderTime.getMinutes().toString().padStart(2, '0'); reminderTime.getMinutes().toString().padStart(2, '0');
window.DailyNotification.scheduleDailyReminder({ window.DailyNotification.scheduleDailyReminder({
id: 'daily-reminder-test', id: 'daily-reminder-test',
@@ -333,14 +337,14 @@
priority: 'default', priority: 'default',
repeatDaily: false // Just for testing repeatDaily: false // Just for testing
}) })
.then(() => { .then(() => {
status.innerHTML = 'Daily reminder scheduled for ' + timeString + '!'; status.innerHTML = 'Daily reminder scheduled for ' + timeString + '!';
status.style.background = 'rgba(0, 255, 0, 0.3)'; // Green background status.style.background = 'rgba(0, 255, 0, 0.3)'; // Green background
}) })
.catch(error => { .catch(error => {
status.innerHTML = `Reminder failed: ${error.message}`; status.innerHTML = `Reminder failed: ${error.message}`;
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
}); });
} catch (error) { } catch (error) {
status.innerHTML = `Reminder test failed: ${error.message}`; status.innerHTML = `Reminder test failed: ${error.message}`;
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
@@ -349,55 +353,72 @@
// Permission management functions // Permission management functions
function checkPermissions() { function checkPermissions() {
console.log('checkPermissions called'); console.log('🔐 checkPermissions called');
console.log('🔐 Plugin available:', !!window.DailyNotification);
const status = document.getElementById('status'); const status = document.getElementById('status');
status.innerHTML = 'Checking permissions...'; status.innerHTML = '🔐 Checking permissions...';
status.style.background = 'rgba(255, 255, 0, 0.3)'; // Yellow background status.style.background = 'rgba(255, 255, 0, 0.3)'; // Yellow background
try { try {
if (!window.DailyNotification) { if (!window.DailyNotification) {
status.innerHTML = 'DailyNotification plugin not available'; console.error('❌ DailyNotification plugin not available');
status.innerHTML = '❌ DailyNotification plugin not available<br>Check console for details.';
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
return; return;
} }
console.log('🔐 Calling checkPermissionStatus...');
window.DailyNotification.checkPermissionStatus() window.DailyNotification.checkPermissionStatus()
.then(result => { .then(result => {
status.innerHTML = `Permission Status:<br> console.log('✅ Permission status result:', result);
Notifications: ${result.notificationsEnabled ? '✅' : '❌'}<br> status.innerHTML = `🔐 Permission Status:<br>
Exact Alarm: ${result.exactAlarmEnabled ? '✅' : '❌'}<br> Notifications: ${result.notificationsEnabled ? '✅ YES' : '❌ NO'}<br>
Wake Lock: ${result.wakeLockEnabled ? '✅' : '❌'}<br> Exact Alarm: ${result.exactAlarmEnabled ? '✅ YES' : '❌ NO'}<br>
All Granted: ${result.allPermissionsGranted ? '✅' : '❌'}`; Wake Lock: ${result.wakeLockEnabled ? '✅ YES' : '❌ NO'}<br>
All Granted: ${result.allPermissionsGranted ? '✅ YES' : '❌ NO'}`;
status.style.background = result.allPermissionsGranted ? status.style.background = result.allPermissionsGranted ?
'rgba(0, 255, 0, 0.3)' : 'rgba(255, 165, 0, 0.3)'; // Green or orange 'rgba(0, 255, 0, 0.3)' : 'rgba(255, 165, 0, 0.3)'; // Green or orange
}) })
.catch(error => { .catch(error => {
status.innerHTML = `Permission check failed: ${error.message}`; console.error('❌ Permission check error:', error);
status.innerHTML = `❌ Permission check failed:<br>${error.message || error}`;
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
}); });
} catch (error) { } catch (error) {
status.innerHTML = `Permission check failed: ${error.message}`; console.error('❌ Permission check exception:', error);
status.innerHTML = `❌ Permission check failed:<br>${error.message || error}`;
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
} }
} }
function requestPermissions() { function requestPermissions() {
console.log('requestPermissions called'); console.log('🔐 requestPermissions called');
console.log('🔐 Plugin available:', !!window.DailyNotification);
const status = document.getElementById('status'); const status = document.getElementById('status');
status.innerHTML = 'Requesting permissions...'; status.innerHTML = '🔐 Requesting permissions...<br>You should see a system permission dialog.';
status.style.background = 'rgba(255, 255, 0, 0.3)'; // Yellow background status.style.background = 'rgba(255, 255, 0, 0.3)'; // Yellow background
try { try {
if (!window.DailyNotification) { if (!window.DailyNotification) {
status.innerHTML = 'DailyNotification plugin not available'; console.error('❌ DailyNotification plugin not available');
status.innerHTML = '❌ DailyNotification plugin not available<br>Check console for details.';
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
return; return;
} }
console.log('🔐 Calling requestNotificationPermissions...');
window.DailyNotification.requestNotificationPermissions() window.DailyNotification.requestNotificationPermissions()
.then(() => { .then(result => {
status.innerHTML = 'Permission request completed! Check your device settings if needed.'; console.log('✅ Permission request result:', result);
status.style.background = 'rgba(0, 255, 0, 0.3)'; // Green background const granted = result.granted || result.status === 'granted';
status.innerHTML = `🔐 Permission Request Result:<br>
Status: ${result.status || 'unknown'}<br>
Granted: ${granted ? '✅ YES' : '❌ NO'}<br>
Alert: ${result.alert ? '✅' : '❌'}<br>
Badge: ${result.badge ? '✅' : '❌'}<br>
Sound: ${result.sound ? '✅' : '❌'}`;
status.style.background = granted ?
'rgba(0, 255, 0, 0.3)' : 'rgba(255, 165, 0, 0.3)'; // Green or orange
// Check permissions again after request // Check permissions again after request
setTimeout(() => { setTimeout(() => {
@@ -405,11 +426,13 @@
}, 1000); }, 1000);
}) })
.catch(error => { .catch(error => {
status.innerHTML = `Permission request failed: ${error.message}`; console.error('❌ Permission request error:', error);
status.innerHTML = `❌ Permission request failed:<br>${error.message || error}`;
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
}); });
} catch (error) { } catch (error) {
status.innerHTML = `Permission request failed: ${error.message}`; console.error('❌ Permission request exception:', error);
status.innerHTML = `❌ Permission request failed:<br>${error.message || error}`;
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
} }
} }
@@ -592,7 +615,7 @@
<script> <script>
// Wait for Capacitor to be ready // Wait for Capacitor to be ready
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function () {
console.log('DOM loaded, waiting for Capacitor...'); console.log('DOM loaded, waiting for Capacitor...');
// Wait for Capacitor to be available // Wait for Capacitor to be available
@@ -613,4 +636,5 @@
}); });
</script> </script>
</body> </body>
</html> </html>