upsertDeviceToken method

Future<void> upsertDeviceToken(
  1. String fcmToken,
  2. String platform
)

Implementation

Future<void> upsertDeviceToken(String fcmToken, String platform) async {
  final userId = _client.auth.currentUser?.id;
  if (userId == null) return;

  await _client.from('device_tokens').upsert({
    'user_id': userId,
    'fcm_token': fcmToken,
    'platform': platform,
    'updated_at': DateTime.now().toIso8601String(),
  }, onConflict: 'user_id,fcm_token');
}