Skip to content

App crashes with trackSessionEnd when push notifications are disabled in system settings while app is running #87

@Berker-Sen

Description

@Berker-Sen

Our Flutter app crashes and restarts when a user disables push notifications in the Android system settings while the app is running in the background. The crash appears to occur during the trackSessionEnd call when the app transitions to the paused/background state.

Environment

CleverPush Flutter SDK Version: cleverpush_flutter: ^1.24.26
Platform: Android
Flutter Version: 3.35.7
Device/Emulator: Android device/emulator
Android Version: 16

Steps to Reproduce

Launch the Flutter app with CleverPush SDK initialized
Grant notification permissions when prompted (or have notifications already enabled)
App initializes CleverPush successfully with autoRegister: true
While app is running in foreground, navigate to Android system settings
Disable push notifications for the app in system settings

Expected Behavior

The app should handle the permission revocation gracefully and continue running in the background without crashing. The SDK should detect that permissions have been revoked and handle session tracking accordingly.

Actual Behavior

The app crashes and restarts immediately upon disabling push notifications in system settings. The crash occurs during the trackSessionEnd operation, which appears to not handle the case where notification permissions have been revoked.

Relevant Debug Report

[log] Version Matched DBVersion <TIMESTAMP> to <TIMESTAMP>
[log] Version Matched
[log] Notification permission status: PermissionStatus.granted
[log] permission check false
[log] Notification permission granted!
[log] TabBarController: setUpNotification called :: true
[log] CleverPush setUpNotification → enabled=true, requestedActive=true
[log] CleverPush: Double-checking permission before init: PermissionStatus.granted

I/flutter (<PID>): CleverPush: Flutter initializing with channelId: YOUR_CHANNEL_ID and autoRegister: true

D/CleverPush(<PID>): Initializing with Channel ID: YOUR_CHANNEL_ID (SDK 1.35.16)
D/CleverPush(<PID>): Retention days: 90
D/CleverPush(<PID>): [HTTP] GET: /channel/YOUR_CHANNEL_ID/config

[log] CleverPush: SDK initialized successfully

D/EGL_emulation(<PID>): app_time_stats: avg=16.68ms min=13.14ms max=22.60ms count=60
D/EGL_emulation(<PID>): app_time_stats: avg=16.61ms min=13.77ms max=19.94ms count=61

D/FirebaseSessions(<PID>): App backgrounded on com.example.app

V/BranchSDK(<PID>): onActivityPaused, activity = com.example.app.MainActivity@<HASH>
V/BranchSDK(<PID>): activityCnt_: 1
V/BranchSDK(<PID>): activitiesOnStack_: [com.example.app.MainActivity@<HASH>]

D/FlutterBranchSDK(<PID>): triggered onActivityPaused: com.example.app.MainActivity
D/VRI[MainActivity](<PID>): visibilityChanged oldVisibility=true newVisibility=false

[log] AppLifeCycleController: onHidden
[log] AppLifeCycleController: onPaused

V/BranchSDK(<PID>): onActivityStopped, activity = com.example.app.MainActivity@<HASH>
V/BranchSDK(<PID>): activityCnt_: 0
V/BranchSDK(<PID>): activityCnt_: reset to 0
V/BranchSDK(<PID>): activitiesOnStack_: [com.example.app.MainActivity@<HASH>]

D/FlutterBranchSDK(<PID>): triggered onActivityStopped: com.example.app.MainActivity

D/CleverPush(<PID>): trackSessionEnd

I/FA(<PID>): Application backgrounded at: timestamp_millis: <TIMESTAMP>

Lost connection to device.

Exited.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions