Skip to Content
Nouvelle documentation Applite - JS SDK, Dart SDK & REST API
Dart SDKTokens de Notification

Tokens de Notification (NotificationTokenApi)

Le module NotificationTokenApi permet de gérer les tokens de notification push des clients pour envoyer des notifications sur leurs appareils.

Accès : client.notificationToken

Méthodes

set

Enregistre ou met à jour un token de notification pour un client.

final response = await client.notificationToken.set( SetNotificationTokenParams( appId: 'app_id', apiKey: 'user_api_key', customerId: 'cust_123', token: 'fcm_token_abc123...', platform: NotificationPlatform.android, deviceId: 'device_unique_id', deviceName: 'Samsung Galaxy S21', ), ); print('Token enregistré: ${response.data.id}');

Si le token existe déjà, il sera mis à jour avec les nouvelles informations d’appareil.

remove

Supprime un token de notification spécifique (déconnexion d’un appareil).

final response = await client.notificationToken.remove( RemoveNotificationTokenParams( appId: 'app_id', apiKey: 'user_api_key', customerId: 'cust_123', token: 'fcm_token_abc123...', ), ); if (response.data.removed) { print('Token supprimé - Appareil déconnecté'); }

removeAll

Supprime tous les tokens d’un client (déconnexion de tous les appareils).

final response = await client.notificationToken.removeAll( RemoveAllNotificationTokensParams( appId: 'app_id', apiKey: 'user_api_key', customerId: 'cust_123', ), ); print('${response.data.removedCount} appareil(s) déconnecté(s)');

Utilisez cette méthode avec précaution. Elle déconnecte le client de tous ses appareils.

list

Liste tous les tokens de notification d’un client.

final response = await client.notificationToken.list( ListNotificationTokensParams( appId: 'app_id', apiKey: 'user_api_key', customerId: 'cust_123', ), ); // Afficher les appareils connectés for (final token in response.data) { print('${token.deviceName ?? "Appareil inconnu"} (${token.platform.name})'); }

Plateformes supportées

EnumValeur JSONDescription
NotificationPlatform.iosIOSApple Push Notification service (APNs)
NotificationPlatform.androidANDROIDFirebase Cloud Messaging (FCM)
NotificationPlatform.webWEBWeb Push Notifications

Gestion des erreurs

Code erreurDescription
customer-not-foundLe client n’existe pas
not-authorizedLa clé API n’a pas les droits nécessaires
invalid-requestToken ou plateforme invalide
Last updated on