public class GenericResponseMessage
{
// indicates result of HTTP API call, 200 = success, 400 = parameter invalid, 500 = internal server error
public int status { get; set; }
// indicates error messages, otherwise null
public string[] message { get; set; }
}
This class is JSON return from controller's action when response to POST request
public class RegisteredTokenRepository
{
public RegisteredTokenRepository(string connectionString);
public async Task RegisterUserTokenAsync(int id, string token);
public async Task<string> GetRegisteredTokenAsync(int emp_id);
public async Task UpdateRegisteredTokenAsync(int id, string newToken);
public async Task DeRegisteredTokenAsync(int id);
}
When one wants to associate mobile token with user.
await RegisterUserTokenAsync(int id, string token);
Return Task. throw InvalidOperationException
when Token already exist in system.
Probably throws SQLiteException
.
Behavior: this method will delete existing token that associated with user and insert new token.
When one wants to deregister mobile token with user.
await DeRegisteredTokenAsync(int id);
Return Task. Probably throw SQLiteException
.
When one wants to update registered token that already associated with user.
await UpdateRegisteredTokenAsync(int id, string newToken);
Return Task. Probably throw SQLiteException
.
Behavior: this method will delete existing token and insert new token.
When one wants to get mobile token.
string token = await GetRegisteredTokenAsync(int id);
Return token string, otherwise null. Probably throw SQLiteException.
public class MobileNotificationSender
{
public MobileNotificationSender(string serverKey, RegisteredTokenRepository tokenRepo);
public RegisteredTokenRepository TokenRepository { get; }
public async Task SendNotification(int id, string title, string body);
}
When one wants to send notification to mobile application.
await SendNotification(int id, string title, string body);
Return Task. throw ArgumentException
when parameter invalid. Probably throw SQLiteException
Behavior: Ignores every error from FCM except Unauthorize, FCMException(500 error code). Will update existing token in database to new token if FCM response specify.