In-App OTA Update (Mobile App)
Author(s)
- Ayon Das
Last Updated Date
2025-02-05
SRS References
- NA
Version History
| Version | Date | Changes | Author |
|---|---|---|---|
| 1.0 | 2025-02-05 | Initial draft | Ayon Das |
Feature Overview
Objective:
Implement a way to create in-app OTA update for the MNSR Upasthit application using Sparkle.
Scope:
The feature will enable seamless in-app updates for users, reducing dependency on app store updates. It will ensure that users are always on the latest version without manual intervention. This feature is focused on Android using Sparkle.
Dependencies:
- Flutter framework
- Sparkle for Android app updates
- Hosted Sparkle XML on our server
- Hosted APK files on our server
- Flutter Download Manager for managing file downloads
- open_file package for installing downloaded files
Requirements
- The app should check for updates automatically when launched.
- Users should receive a prompt when a new version is available.
- The update process should be smooth with minimal user interaction.
- Ensure compatibility with Flutter framework and Android platform.
- Provide fallback mechanisms if OTA updates fail.
Design Specifications
-
UI/UX Design:
- A pop-up/modal that notifies users about the new version.
- A progress indicator during the update process.
- An option to defer updates if not mandatory.
-
Third-Party Integrations:
- Sparkle for Android app updates.
- Flutter Download Manager for handling file downloads.
- open_file package for opening and installing APKs.
-
Workflow:
- App checks for updates at startup.
- If an update is available, show a modal with release notes and an update button.
- On user confirmation, download and install the update.
- Handle failures gracefully with retry mechanisms.
-
Downloading & Installing Updates in Flutter:
- Android: Use
flutter_downloaderto download the APK to the app's private directory, then install it usingopen_file.
Example Code for Download & Installation:
import 'dart:io';
import 'package:path_provider/path_provider.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:open_file/open_file.dart';
void downloadAndInstall(String url, String fileName) async {
final directory = await getApplicationSupportDirectory();
final filePath = "${directory.path}/$fileName";
final taskId = await FlutterDownloader.enqueue(
url: url,
savedDir: directory.path,
fileName: fileName,
showNotification: true,
openFileFromNotification: true,
);
FlutterDownloader.registerCallback((id, status, progress) {
if (status == DownloadTaskStatus.complete) {
OpenFile.open(filePath);
}
});
}Required Android Permissions:
In
AndroidManifest.xml, add:<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>Scoped Storage Considerations:
- The APK file will be stored in the app's private directory (
getApplicationSupportDirectory()), eliminating the need for external storage permissions.
- Android: Use
Development Tasks & Estimates
| No | Task Name | Estimate (Hours) | Dependencies | Notes |
|---|---|---|---|---|
| 1 | Setup Upgrader (Appcast) for Flutter | 4 hours | Flutter Setup | |
| 2 | UI Design for update prompt | 2 hours | UI/UX Designs | |
| 3 | Host Sparkle XML and APK files | 6 hours | Server Setup | |
| 4 | Implement file download and installation | 4 hours | Download Manager | |
| 5 | Testing & debugging | 4 hours | QA Team | |
| 6 | Total | 24 hours |
Testing & Quality Assurance
-
Unit Tests:
- Validate XML parsing for updates.
- Ensure correct handling of version information.
-
Integration Tests:
- Verify smooth transition between versions.
- Check failure handling when updates fail.
-
Acceptance Criteria:
- The app prompts users when an update is available.
- Users can install the update with minimal steps.
- The process works reliably on Android.
-
Testing Tools:
- Flutter Test Framework
- Firebase Test Lab
Deployment Considerations
-
Configuration Changes:
- Ensure Sparkle XML is correctly hosted on the server.
- Ensure APK files are accessible from the update URL.
-
Rollout Plan:
- Beta testing with a limited user base.
- Gradual rollout to all users.
- Monitor crash reports and user feedback.
Risks & Mitigations
| Risk | Impact | Likelihood | Mitigation Strategy |
|---|---|---|---|
| Users ignore update prompts | Medium | High | Make updates mandatory if necessary |
| OTA update fails due to network issues | High | Medium | Implement retry mechanisms |
| Compatibility issues with older versions | High | Medium | Ensure backward compatibility |
Review & Approval
-
Reviewer:
Ayon Das -
Approval Date:
2025-02-07
Notes
- Ensure proper logging of update failures for debugging.
- Consider adding analytics for tracking update adoption rates.
- Verify correct storage permissions for downloads on Android.