Utils

object Utils

Utility object providing various helper functions for the MTN MOMO SDK sample application.

This object contains methods for saving and retrieving API keys and access tokens, as well as checking token expiration and formatting dates.

Functions

Link copied to clipboard
fun convertToDate(milliseconds: Long): String

Converts the given milliseconds to a formatted date string.

Link copied to clipboard

Retrieves the saved access token from shared preferences.

Link copied to clipboard
fun getApiKey(context: Context): String

Retrieves the saved API key from shared preferences.

Link copied to clipboard
Link copied to clipboard

Retrieves the product subscription keys based on the specified product

Link copied to clipboard
fun saveAccessToken(context: Context, accessToken: AccessToken?)

Saves the provided access token in the shared preferences along with its expiry date.

Link copied to clipboard
fun saveApiKey(context: Context, apiKey: String)

Saves the provided API key in the shared preferences.

Link copied to clipboard
fun saveOauth2AccessToken(context: Context, oauth2AccessToken: Oauth2AccessToken?)