The logs will contain the notification tokens involved in the notification.
Extraction of push notification tokens by person
Push notification tokens are stored inAmetys user preferences. It is possible to extract tokens for each person.
This script is used to obtain the connection ID of each person subscribed to the mobile app's push notifications:
Oops!
Copy to clipboard failed. Open the code and copy it manually.
let population = "utilisateurs";
const UserPreferencesHelper = Ametys.serviceManager.lookup("org.ametys.plugins.mobileapp.UserPreferencesHelper");
printNotificationTokens("loginDeLUtilisateur");
function printNotificationTokens(login){
let user = org.ametys.core.user.UserIdentity.stringToUserIdentity(`${login}#${population}`);
Ametys.console.log(login+":"+UserPreferencesHelper.getNotificationTokens(user).toString());
}
let population = "utilisateurs";
const UserPreferencesHelper = Ametys.serviceManager.lookup("org.ametys.plugins.mobileapp.UserPreferencesHelper");
printNotificationTokens("loginDeLUtilisateur");
function printNotificationTokens(login){
let user = org.ametys.core.user.UserIdentity.stringToUserIdentity(`${login}#${population}`);
Ametys.console.log(login+":"+UserPreferencesHelper.getNotificationTokens(user).toString());
}
let population = "utilisateurs";
const UserPreferencesHelper = Ametys.serviceManager.lookup("org.ametys.plugins.mobileapp.UserPreferencesHelper");
printNotificationTokens("loginDeLUtilisateur");
function printNotificationTokens(login){
let user = org.ametys.core.user.UserIdentity.stringToUserIdentity(`${login}#${population}`);
Ametys.console.log(login+":"+UserPreferencesHelper.getNotificationTokens(user).toString());
}
Replace "loginDeLUtilisateur" with the user's login. You can add as many printNotificationTokens("loginDeLUtilisateur"); lines as you like to obtain the tokens for each of these people.
Revoker a token (not to be confused with notification tokens)
When a user authenticates on the mobile app, a personal token dedicated to the mobile app is assigned. It is this token that then enables the user to authenticate via the mobile app.
Tokens are stored in the database in the Authentication_Token table, and are encoded to prevent anyone reading the database from using the token.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
All tokens created for the mobile application have the 'mobileapp' type.
To delete all a user's tokens from their mobile application login :
Oops!
Copy to clipboard failed. Open the code and copy it manually.
delete from Authentication_Token where type='mobileapp' and login='xxx';
delete from Authentication_Token where type='mobileapp' and login='xxx';
delete from Authentication_Token where type='mobileapp' and login='xxx';
You can force tokens to be deleted automatically using a script shell launched in a crontab, for example, based on the creation date, to delete all mobile app tokens older than 6 months.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
delete from Authentication_Token where type='mobileapp' and creation_date < date_sub(now(), Interval 6 month);
delete from Authentication_Token where type='mobileapp' and creation_date < date_sub(now(), Interval 6 month);
delete from Authentication_Token where type='mobileapp' and creation_date < date_sub(now(), Interval 6 month);