🔔 Push notifications
Notifications go through Firebase Cloud Messaging (FCM). You register an FCM token for each account, and EcoleDirecte's server pushes to it.
Get the FCM token
The official app uses the Capacitor plugin @capacitor-firebase/messaging: ask for the notification permission, then FirebaseMessaging.getToken(). A token only works with the Firebase project that issued it, so it must come from EcoleDirecte's Firebase app:
| Firebase value | |
|---|---|
| Project id | ecoledirecte-6ed70 |
Sender id (gcm_defaultSenderId) | 288752977018 |
Android app id (google_app_id) | 1:288752977018:android:7fc1318d518367f4 |
| Android package | com.ecoledirecte.edmobile |
| API key | google_api_key in the Android APK res/values/strings.xml |
An FCM token is bound to the Firebase project that issued it, so it has to come from EcoleDirecte's own Firebase app (above), not from your own project.
Register a push token
Right after login, and again whenever the token changes. One registration per account.
data={
"idUser": 1234567, // account.id
"codeOgec": "0123456A", // account.codeOgec
"role": "E", // account.typeCompte
"registrationToken": "fCm0Tok3n:APA91bH…", // FCM token, see Push notifications
"oldRegistrationToken": "0ldTok3n:APA91bG…", // optional. Previous token, when it changed
"instanceId": "android" // ios, android or navigator
}
Unregister a push token
Same body, without oldRegistrationToken.
data={
"idUser": 1234567, // account.id
"codeOgec": "0123456A", // account.codeOgec
"role": "E", // account.typeCompte
"registrationToken": "fCm0Tok3n:APA91bH…", // FCM token, see Push notifications
"instanceId": "android" // ios, android or navigator
}
What you receive
An FCM message with notification.title, notification.body and a data map:
{ "notification": { "title": "…", "body": "…" }, "data": { "command": "Messagerie" } }
data.command | What the app does |
|---|---|
Generique | Shows title and body in a toast when logged in |
Messagerie | Opens MESSAGERIE |
Documents | Opens DOCUMENTS_ELEVE for a student, DOCUMENTS otherwise |
CarnetCorrespondance | Opens CARNET_CORRESPONDANCE (student, teacher, staff) |
InscriptionReinscription | Opens the home screen (family, DOSSIER_INSCRIPTION enabled) |
QCM | Opens QCM |
EDFORMS | Opens the home screen |
The module is opened only when it is enabled, and its screen is reloaded.