Skip to main content
Version: MNSR

In-App OTA Update (Mobile App)

Author(s)

  • Ayon Das

Last Updated Date

2025-02-05


SRS References

  • NA

Version History

VersionDateChangesAuthor
1.02025-02-05Initial draftAyon 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

  1. The app should check for updates automatically when launched.
  2. Users should receive a prompt when a new version is available.
  3. The update process should be smooth with minimal user interaction.
  4. Ensure compatibility with Flutter framework and Android platform.
  5. 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:

    1. App checks for updates at startup.
    2. If an update is available, show a modal with release notes and an update button.
    3. On user confirmation, download and install the update.
    4. Handle failures gracefully with retry mechanisms.
  • Downloading & Installing Updates in Flutter:

    • Android: Use flutter_downloader to download the APK to the app's private directory, then install it using open_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.

Development Tasks & Estimates

NoTask NameEstimate (Hours)DependenciesNotes
1Setup Upgrader (Appcast) for Flutter4 hoursFlutter Setup
2UI Design for update prompt2 hoursUI/UX Designs
3Host Sparkle XML and APK files6 hoursServer Setup
4Implement file download and installation4 hoursDownload Manager
5Testing & debugging4 hoursQA Team
6Total24 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

RiskImpactLikelihoodMitigation Strategy
Users ignore update promptsMediumHighMake updates mandatory if necessary
OTA update fails due to network issuesHighMediumImplement retry mechanisms
Compatibility issues with older versionsHighMediumEnsure 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.