fix(android): resolve permission request and status display issues
- Add requestPermissions method alias to fix Vue app compatibility - Fix permission response format to include both string and boolean values - Add comprehensive debugging for permission request flow - Implement permission request throttling to prevent app crashes - Fix capacitor.settings.gradle plugin path configuration - Enhance Vue app logging for permission status debugging Resolves permission dialog not appearing and UI showing incorrect status. All permission functionality now works end-to-end with proper status updates.
This commit is contained in:
@@ -3,4 +3,4 @@ include ':capacitor-android'
|
||||
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
|
||||
|
||||
include ':timesafari-daily-notification-plugin'
|
||||
project(':timesafari-daily-notification-plugin').projectDir = new File('../../../android/plugin')
|
||||
project(':timesafari-daily-notification-plugin').projectDir = new File('../node_modules/@timesafari/daily-notification-plugin/android/plugin')
|
||||
|
||||
@@ -111,6 +111,7 @@ const appStore = useAppStore()
|
||||
|
||||
const isScheduling = ref(false)
|
||||
const isCheckingStatus = ref(false)
|
||||
const isRequestingPermissions = ref(false)
|
||||
|
||||
const platformName = computed(() => {
|
||||
const platform = appStore.platform
|
||||
@@ -215,6 +216,12 @@ const checkSystemStatus = async (): Promise<void> => {
|
||||
console.log(' - error:', status.error)
|
||||
|
||||
console.log('📊 Plugin permissions:', permissions)
|
||||
console.log('📊 Permissions details:')
|
||||
console.log(' - notifications:', permissions.notifications)
|
||||
console.log(' - notificationsEnabled:', (permissions as any).notificationsEnabled)
|
||||
console.log(' - exactAlarmEnabled:', (permissions as any).exactAlarmEnabled)
|
||||
console.log(' - wakeLockEnabled:', (permissions as any).wakeLockEnabled)
|
||||
console.log(' - allPermissionsGranted:', (permissions as any).allPermissionsGranted)
|
||||
console.log('📊 Exact alarm status:', exactAlarmStatus)
|
||||
|
||||
// Map plugin response to app store format
|
||||
@@ -239,12 +246,38 @@ const checkSystemStatus = async (): Promise<void> => {
|
||||
// Log permission status for debugging
|
||||
if (!mappedStatus.postNotificationsGranted) {
|
||||
console.warn('⚠️ Notification permissions not granted - user needs to enable in settings')
|
||||
console.log('🔧 Testing permission request...')
|
||||
try {
|
||||
await plugin.requestPermissions()
|
||||
console.log('✅ Permission request completed')
|
||||
} catch (permError) {
|
||||
console.error('❌ Permission request failed:', permError)
|
||||
|
||||
// Only request permissions if not already requesting
|
||||
if (!isRequestingPermissions.value) {
|
||||
console.log('🔧 Testing permission request...')
|
||||
isRequestingPermissions.value = true
|
||||
|
||||
// Enhanced debugging for permission request
|
||||
console.log('🔍 DEBUG: Plugin object:', plugin)
|
||||
console.log('🔍 DEBUG: Plugin type:', typeof plugin)
|
||||
console.log('🔍 DEBUG: requestPermissions method:', typeof plugin.requestPermissions)
|
||||
console.log('🔍 DEBUG: Available methods:', Object.getOwnPropertyNames(plugin))
|
||||
|
||||
try {
|
||||
console.log('🔍 DEBUG: About to call plugin.requestPermissions()')
|
||||
const result = await plugin.requestPermissions()
|
||||
console.log('✅ Permission request completed, result:', result)
|
||||
|
||||
// After permission request, refresh the status
|
||||
console.log('🔄 Refreshing status after permission request...')
|
||||
await checkSystemStatus()
|
||||
} catch (permError) {
|
||||
console.error('❌ Permission request failed:', permError)
|
||||
console.error('❌ Error details:', {
|
||||
name: permError.name,
|
||||
message: permError.message,
|
||||
stack: permError.stack
|
||||
})
|
||||
} finally {
|
||||
isRequestingPermissions.value = false
|
||||
}
|
||||
} else {
|
||||
console.log('⏳ Permission request already in progress, skipping...')
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user