Preparation by Alonso - ISIS3510-MOBILE-T34/T34-Wiki-SpendiQ GitHub Wiki
1. Eventual Connectivity Strategy Implemented: ECS3 from Wiki - about CAS feature
The app constantly checks the connectivity state of the user with the Implemented Service: ReachabilityManager which is an observable singleton object that publishes the state of the device: offline or online.
This check is mainly done by the monitor: NWPathMonitor()
When offline, notes are shown to inform the user and the caching strategies are used to fulfill the 'Network falling back to cache' strategy chosen. The notes are shown in the bubble offer lists and in the detailed views of the offers.
The OfferViewModel is the main responsible of checking the connectivity status and deciding whether to load cached data or fetch data from Firebase.
2. Caching Strategies
a. Saving into Cache with CoreData and a DataModel created the information of the fetched Offers
When Offline, the cached data is shown completely, including the Offer Detailed view, to not lose the CAS feature value.
Important files: OfferViewModel, OfferBubbleView, OfferDetailView
b. Saving the images of the shops into Cache using a shared Singleton of ImageCacheManager
This is done when a new offer is fetched by using:
cacheDirectory.appendingPathComponent(key) and guard let data = image.jpegData(compressionQuality: 0.8)
both in the list of offers and the Offer detailed view.
Important files: OfferViewModel, OfferBubbleView, OfferDetailView
3. Multi-Threading / Concurrency Strategies
a. Location Manager: Background thread for database (offers documents in FireBase) querying using DispatchQueue.global. This ensures the database fetch operation doesn't block the main thread, and improves app responsiveness.
Code Snippet: "DispatchQueue.global(qos: .userInitiated).async {guard let documents = snapshot?.documents else { return } ... }"
b. Location Manager: Using a background thread for downloading images using URLSession. These images are the one used in the Offers notification to the users. This offloads image download tasks from the main thread, which ensures smooth UI performance.
Code Snippet: "DispatchQueue.global(qos: .utility).async {let dataTask = URLSession.shared.dataTask(with: url) ... } "
4. Local Storage Strategies
1. Persistent Notified Offers (Proximity to Offers)
-
Description:
Stores notified offer IDs permanently inUserDefaults
to ensure users never receive the same offer notification again. -
Changes Made:
- File:
LocationManager.swift
- Methods:
loadNotifiedOffers
: Loads notified offers fromUserDefaults
.saveNotifiedOffers
: Saves notified offers toUserDefaults
.addNotifiedOffer
: Adds a new offer ID to the local storage.isOfferNotified
: Checks if an offer has already been notified.- Updated:
checkProximityToOffers
to integrate the storage logic.
- File:
2. Monthly Financial Snapshot (Overview of the Month)
-
Description:
Caches the total income and expenses for the current month inUserDefaults
, reducing database queries and improving performance. -
Changes Made:
- File:
TransactionViewModel.swift
- Methods:
saveMonthlySnapshot
: Saves the monthly financial snapshot toUserDefaults
.loadMonthlySnapshot
: Loads the snapshot if it matches the current month.- Updated:
calculateMonthlyIncomeAndExpenses
to use cached data before querying Firestore.
- File:
5. Implementation of my New Sprint 3 BQ with a new Feature as well (Feature 7)
What is the total amount of income versus expenses incurred by the user in the current month across all registered accounts?
Justification:
This business question aligns with the newly implemented functionality F7, which provides an overview of the user's total income and expenses for the current month. This feature presents a visually distinct summary of the user's financial activities directly on the homepage, allowing them to quickly assess their financial status. By offering users insights into their income and expenses, the app promotes better financial awareness, enabling users to identify trends, make adjustments, and plan their finances more effectively. The feature’s placement on the homepage ensures immediate visibility, emphasizing its importance in fostering informed financial decisions.
Why It Is Type 2:
This question is classified as a Type 2 business question because it delivers tailored, user-focused information that enhances their interaction with the app. By summarizing financial data in a meaningful and easy-to-understand format, the feature supports user engagement and retention. This functionality not only adds value by presenting actionable insights but also aligns with the app's goal of empowering users to manage their finances confidently. It directly contributes to user satisfaction by providing a key piece of information critical for achieving their financial objectives, demonstrating the app’s commitment to user-centric design.
### Feature F7 ECS
It follows Local storage falling back to network. If the user has a local financial snapshot about the total expenses and incomes in the current month, the app loads that instead of doing the calculations from zero with firebase data.