Analysis of the Possibility to Implement an Eventual Connectivity Scenario in Each Functionality and Definition of Ideas to Handle Local Storage and Data Synchronization - ISIS3510-MOBILE-T34/T34-Wiki-SpendiQ GitHub Wiki
F1 (Using Phone Sensors): Possible
Biometric sensors operate offline.
Biometric sensors used as a means to log in will be enabled after the user has registered for the first time and confirmed their email account with Two-Factor Authentication (a code sent to their email).
Using Google Maps or Apple Maps in the way required by SpendiQ requires internet access. Therefore, in the absence of a connection, a strategy must be adapted to ensure F1 continues to function.
In the Firebase database, the information of the last recorded position for each user will be maintained. This position will be updated every minute locally in the device cache and every 5 minutes remotely in Firebase to always have a record of the last detected position for a person and to calculate recommendations to send to the user.
If it is not possible to send the update to Firebase due to no internet, that attempt will be skipped and retried in the next 5 minutes. The current GPS location will always remain updated locally in the cache (every 1 minute).
Clarification: Recommendations and their justifications, as well as expense reports, must be handled in Firebase; hence, it serves as an analytics engine.
F2 (Responding to BQ Type 2): Possible
To generate graphs that provide information about expenses and their behavior per user, internet access is not necessary if this information is periodically stored in the phone's secondary storage.
For this, expense data (detailed, daily expenses, and income for the last 7 days) will be stored in the phone's secondary storage. When there is a connection, this information will be synchronized with the cloud data in Firebase. Synchronizations will be attempted as soon as the user regains internet connection.
F3 (Context-Sensitive (CAS)): Possible
Instead of disabling the service when there is no internet, the information from the last location scan and the list of recommendations provided by the app can be stored in cache storage. The app will display that there is no connection and that the list of recommendations will update once a connection is available. However, the last loaded list will appear, and users will be able to view the details, including the map with the stored latitude and longitude positions.
If there is no data in the cache and no connection, the user will be informed that internet access is required to access the list of recommendations.
Connection verification and position updates will be attempted every 10 minutes. If unsuccessful, the locally stored data will continue to be displayed along with a warning about the need for a connection to update.
F4 (Smart Feature): Possible
Similarly to F3 of the CAS, the justifications for the recommendations periodically provided to a user require internet access to be updated and retrieved from the Analytics Engine.
However, when there is no internet connection, the last recommendations for stores/restaurants along with their machine learning-based justifications will be maintained locally. These latest recommendations sent from Firebase, as well as their justifications, will be stored in the device's CACHE, not in secondary storage. Therefore, when there is no internet and no recommendations are stored, the user will be notified that internet access is necessary to access this feature.
If there is no internet and there are stored recommendations, they will be displayed to the user along with a notice that they are not updated due to the lack of internet.
F5 (User Authentication): Possible
The app will not have an 'anonymous user' mode; therefore, whenever accessing functionalities within the app, the user must first authenticate with their username and password (or a biometric sensor such as a fingerprint or face recognition). When a user has not authenticated and there is no internet, a notification will indicate that a connection is required to authenticate.
The app will have an offline mode:
Since it handles information about expenses and income in bank accounts, login information will not be stored in secondary memory for more than 7 days.
It is necessary to log in with a username and password each time the app is reopened (or with biometric information). This username and password will be validated locally to allow the person to access their account without internet.
Only one user's information can be stored locally, so without internet, it is not possible for a different person to access their account.
If the user is registering, the two-factor authentication process will be used, which involves sending an email with a confirmation code. It is not possible to register in the app without internet.
Each time the user opens the app, the date of their last session will be checked locally. If it exceeds 7 days, the data in the device's secondary memory will be deleted, requiring the user to log in again without the possibility of doing so without internet or with fingerprint or Face-ID.
The information about the last session recorded for each user will also be maintained in the cloud, in the app's Firestore database. This information will be synchronized whenever the user enters the app (regardless of whether they log in or not).
If there is no internet, the last session synchronization will not occur. This will be retried as soon as the internet connection is restored. There is an attribute in the Firebase 'users' collection where the user's last session date is stored; this is the field that will be synchronized when there is a connection and the user logs into the app again (bringing it to the foreground).
The information about the last login is important for the development team to evaluate app usage and motivate usage through marketing.
F6 (Using External Services): Not Possible
To perform two-factor authentication, internet access is required on any device that has the registered email or WhatsApp contact number.
Internet access is necessary on the mobile device to verify that the code entered by the user is correct.
Therefore, it is not possible to implement an eventual connectivity scenario for this functionality.
Proposed New Functionality That Allows It Instead:
New Functionality: F7 (Related to a BQ Type 2)
As an extra feature that may be appreciated by users, the main view of the app (Home) will display the total amount of money spent versus the total amount received in the last month across all registered accounts.
This information will be visible as soon as the user enters the app, providing control information and quick access.
Remember that the phone only stores detailed daily expenses and income for the last 7 days in secondary memory.
This information can function without internet access, as only two values will be stored in the device's secondary memory (total money spent in the last 30 days and total income in the last 30 days). These will not be detailed by day as those stored for generating graphs.
Because information about each expense and income in the last week is stored in secondary memory to later attempt synchronization upon recovering an internet connection, this dashboard can always update in real-time without internet.
The updated dashboard information will be attempted to be synchronized with the cloud each time the user regains internet connection. Therefore, it will always function offline with local data. If the user deletes the local information, they must have internet access to log into their account again, ensuring that monthly expense and income information cannot be desynchronized for a period longer than 7 days.