handleAuthenticated method
Public handler for auth state changes. Called when user authenticates.
Can be passed to the AuthService constructor for race-free initialization (see the DeviceServiceInt class documentation's manual-wiring example).
Unlike DeviceService, NotificationService's _handleLogin doesn't actually
need _authService (it only uses configuration and local state). However,
the defensive warning helps surface initialization ordering issues.
Implementation
Future<void> handleAuthenticated(String? uid) async {
// Defensive check - warn if called before initialize().
// Unlike DeviceService, NotificationService's _handleLogin() doesn't actually
// need _authService (it only uses configuration and local state). However,
// logging helps surface initialization ordering issues.
if (_authService == null) {
logw('NotificationService: handleAuthenticated called before initialize(). '
'Proceeding anyway (_handleLogin has no auth dependency). '
'This may indicate an initialization ordering issue (callbacks should '
'be registered before the auth listeners attach).');
}
logd('NotificationService: handleAuthenticated called, uid=$uid');
await _handleLogin();
}