unregisterDeviceToken method
Unregisters this device's FCM token from the backend.
Call this method when the user logs out or wants to stop receiving notifications. This removes the device token from the backend database.
Parameters:
subSystemId: Optional subsystem identifier for multi-tenant appsappCode: Application code for backend identification
Implementation
Future<void> unregisterDeviceToken({
int? subSystemId,
required String appCode,
}) async {
if (!await hasNotificationPermission() || _deviceToken == null) return;
final deviceInfo = SupaArchitecturePlatform.instance.deviceInfo;
final deviceToken = DeviceNotificationToken(
osVersion: deviceInfo.systemVersion,
deviceId: deviceInfo.deviceUuid,
deviceModel: deviceInfo.deviceModel,
token: _deviceToken!,
subSystemId: subSystemId,
appCode: appCode,
);
try {
_deviceToken = null;
await _notificationRepository.deleteToken(deviceToken);
} catch (error) {
debugPrint("Failed to unregister device token: ${error.toString()}");
}
}