Flutter package to embed native in-app updater

Overview

native_updater

pub package

Flutter package for prompting users to update with a native dialog whether using the app store version or any version at the user's discretion.

When a latest app version is available via user defined logic, a simple alert prompt widget is displayed. With today's modern app stores, there is little need to persuade users to update because most of them are already using the auto update feature. However, there may be times when an app needs to be updated more quickly than usual, and nagging a user to update will entice the update sooner.

The UI comes in two flavors: Material Design for Android and Cupertino for iOS. The UpdateMaterialAlert widget is used to display the native Android alert prompt, and the UpdateCupertinoAlert widget is used to display the native iOS alert prompt.

Installation via GitHub (for test only)

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.3

  # Add this inside pubspec.yaml
  native_updater:
    git: https://github.com/loadsmileau/native_updater

Setup

Android

Already good to go.

iOS

To be able to show your App Name in the Cupertino Alert Dialog, add the following keys to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

<key>CFBundleDisplayName</key>
<string>YOUR APP NAME</string>

Usage

Just add this code whenever you want to display the update alert, and it will handle the rest.

NativeUpdater.displayUpdateAlert(
  context,
  forceUpdate: true,
);

Or with the optional parameters to customize the alert.

NativeUpdater.displayUpdateAlert(
  context,
  forceUpdate: true,
  appStoreUrl: '<Your App Store URL>',
  playStoreUrl: '<Your Play Store URL>',
  iOSDescription: '<Your iOS Description>',
  iOSUpdateButtonLabel: '<Your iOS Update Button Label>',
  iOSCloseButtonLabel: '<Your iOS Close Button Label>',
  iOSIgnoreButtonLabel: '<Your iOS Ignore Button Label>',
  iOSAlertTitle: '<Your Dialog Title>',
);

Parameters Explanation

Required Parameters

context is the location in the tree where this widget builds.

forceUpdate is to tell whether the alert is forcing an update or not. Set to true if you are forcing an update. Set to false if you are giving an option to update later.

Optional Parameters

appStoreUrl is to launch your App Store URL if you're developing for iOS. Follow this link on how to find your App Store URL.

playStoreUrl is to launch your Play Store URL if you're developing for Android. Follow this link on how to find your Play Store URL.

iOSDescription is to use your custom alert description on UpdateCupertinoAlert. The default is <App Name> requires that you update to the latest version. You cannot use this app until it is updated. or <App Name> recommends that you update to the latest version. You can keep using this app while downloading the update.

iOSUpdateButtonLabel is used to set your custom Update Button Label on UpdateCupertinoAlert. The default is Update.

iOSCloseButtonLabel is used to set your custom Close Button Label onUpdateCupertinoAlert. The default is Close App.

iOSIgnoreButtonLabel is used to set your custom Ignore Button Label onUpdateCupertinoAlert. The default is Later.

iOSAlertTitle is used to set your custom Dialog Title onUpdateCupertinoAlert. The default is Update Available.

Full Example

import 'package:flutter/material.dart';
import 'package:native_updater/native_updater.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'native_updater example',
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  void initState() {
    super.initState();
    checkVersion();
  }

  Future<void> checkVersion() async {
    /// For example: You got status code of 412 from the
    /// response of HTTP request.
    /// Let's say the statusCode 412 requires you to force update
    int statusCode = 412;

    /// This could be kept in our local
    int localVersion = 9;

    /// This could get from the API
    int serverLatestVersion = 10;

    Future.delayed(Duration.zero, () {
      if (statusCode == 412) {
        NativeUpdater.displayUpdateAlert(
          context,
          forceUpdate: true,
          appStoreUrl: '<Your App Store URL>',
          playStoreUrl: '<Your Play Store URL>',
          iOSDescription: '<Your iOS description>',
          iOSUpdateButtonLabel: 'Upgrade',
          iOSCloseButtonLabel: 'Exit',
        );
      } else if (serverLatestVersion > localVersion) {
        NativeUpdater.displayUpdateAlert(
          context,
          forceUpdate: false,
          appStoreUrl: '<Your App Store URL>',
          playStoreUrl: '<Your Play Store URL>',
          iOSDescription: '<Your description>',
          iOSUpdateButtonLabel: 'Upgrade',
          iOSIgnoreButtonLabel: 'Next Time',
        );
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Your App'),
      ),
      body: Center(
        child: Text('Testing...'),
      ),
    );
  }
}

Screenshots of Material Alert

An example of a flexible update flow

image

An example of an immediate update flow

image

Screenshots of Cupertino Alert

Force Update Can Update Later
image image
Comments
  • how get http statusCode?

    how get http statusCode?

    Hi, in example you describe that I need to get http status code by a requisition. You would send us a example? Or send to us a link thet document this process?

    /// For example: You got status code of 412 from the /// response of HTTP request. /// Let's say the statusCode 412 requires you to force update int statusCode = 412;

    thanks

    opened by marleynoleto 4
  • update button custom text fix, added modal window custom title text

    update button custom text fix, added modal window custom title text

    Hi, I have to thank you guys for this awesome package. I just made a few changes.

    1. I added custom text to update button (it was prepared but not used)
    2. I added custom text for modal window title (on same way like other custom texts in UpdateCupertinoAlert)
    opened by 10peter10 3
  • Additional widget customization

    Additional widget customization

    This is basically https://github.com/ofload/native_updater/pull/22

    Fulfills first and second point of https://github.com/ofload/native_updater/pull/22#issuecomment-866836810 I hope that @Macacoazul01 don't mind as lots of code belongs to him :)

    @milhomem could you take a look?

    opened by plblueraven 2
  • Null check operator used on a null value

    Null check operator used on a null value

    _CastError: Null check operator used on a null value File "native_updater.dart", line 79, in NativeUpdater._showCupertinoAlertDialog File "native_updater.dart", line 58, in NativeUpdater.displayUpdateAlert

    opened by elnurxf 2
  • Null safety refactor

    Null safety refactor

    This pr contains 3 commits:

    1. Migrated dependencies to null safety dependencies
    2. migrated Flat Button deprecated widget To TextButton
    3. Migrate a few params to optional

    Why are the changes done: Flutter 2.0 has introduced null safety, Now every new version of popular libraries(firebase, http, e.t.c.) recent releases only support null safety and now support for Flutter1.0 is getting thinner. Any flutter project has now to choose either to embrace completely null safety or stay with stale packages(missing out latest fixes and features). Having best of both world is now very tiresome. For more: understanding null safety

    Now The projects who have migrated to null safety or started with null safety can not use native_updator as it has no null safety version. People like these( i recently migrated my project to null safety as I wanted to update firebase dependencies for which null safety is a must) have no choice other than moving out of native_updator.

    With flutter 2.0 FlatButtons got deprecated in favour of TextButtons FlatButtons

    opened by nischalkumar 2
  • Integrate In App Update

    Integrate In App Update

    To perform the update natively, we should implement Play Core library to request and perform a flexible or immediate in-app update. To avoid reinventing the wheel, I try to integrate an existing plugin to do that.

    opened by JeffryHermanto 2
  • Dialog not shown when App on Playstore

    Dialog not shown when App on Playstore

    I'm very appreciate your work for in app update. But one thing I notice that update dialog not shown when an app is already on play store even the version number and code is different. I used latest native_updater version 0.1.0 Please look into this.

    opened by SyedAmmarSohail 1
  • Force update does not really force an update.

    Force update does not really force an update.

    Users can easily dismiss the dialog box. Now since this is a native window, you may not have the ability to change the UI. Although be any chance is it possible to notify the user's choice by a callback?

    opened by praharshbhatt 1
  • Add support for checking for versions

    Add support for checking for versions

    It would be awesome if the library could also support a basic update check, using the "standard" APIs, i.e. google play and the iTunes store. To support this, the following would have to be done.

    • use https://pub.dev/packages/package_info to get the version name/code
    • use the version code provided by in_app_update for android
    • use the itunes API to get the newest ios version (See https://pub.dev/packages/upgrader#itunes-search-api for a package that can do that)
    • provide a checkForUpdates method (or similar), something like the following:
    enum UpdateLevel { skip, optional, required }
    
    NativeUpdater.checkForUpdates(
      BuildContext context, {
      UpdateLevel Function(int, int) androidCompareVersion,  // compare version code aka. build number
      UpdateLevel Function(String, String) iosCompareVersion,  // compare version string
      // other parameters from displayUpdateAlert, except forceUpdate, which is replaced by the UpdateLevel result
    });
    

    We need two methods for comparing, because on android, the version code / build number is used by google play, while on iOS the actual public version string is used.

    opened by felix-barz-brickmakers 1
  • Integrate In App Update

    Integrate In App Update

    To perform the update natively, we should implement Play Core library to request and perform a flexible or immediate in-app update. To avoid reinventing the wheel, I try to integrate an existing plugin to do that. It's common for a package to depend on another package in pub.dev

    opened by JeffryHermanto 0
  • Add Play Store URL Parameter

    Add Play Store URL Parameter

    To avoid confussion on why only App Store URL asked, we think it’s fair enough to request the user to set both urls (App Store & Play Store). I also revised the necessary files regarding this changes.

    opened by JeffryHermanto 0
  • Error while compiling

    Error while compiling

    /flutter/.pub-cache/hosted/pub.dartlang.org/in_app_update-2.0.0/android/src/main/kotlin/de/ffuf/in_app_update/InAppUpdatePlugin.kt: (226, 26): Type mismatch: inferred type is String? but String was expected

    FAILURE: Build failed with an exception.

    opened by Takabrycheri 0
  • native_updater package is not working building apk with --split-per-abi

    native_updater package is not working building apk with --split-per-abi

    In my project, I test in debug and building apk with flutter build apk command, and this package work for them, but if I build it with —split-per-abi, it doesn't work. What could I do on this ?

    opened by normatov07 0
  • chore(dependencies): update dependencies to the latest release and minor refactoring

    chore(dependencies): update dependencies to the latest release and minor refactoring

    Status

    READY

    Breaking Changes

    NO

    Description

    • Remove deprecated Flutter Android v2 Embedding usages, including in example app
    • Update a dependency to the latest release. (package_info_plus, url_launcher, in_app_update)
    • Bump Dart SDK version from 2.12.0 to 2.17.0
    • Refactor update_cupertino_alert.dart and update_material_alert.dart to use launchUrl method instead of launch method since the launch method in url_launcher plugin is depreacted

    Type of Change

    • [ ] ✨ New feature (non-breaking change which adds functionality)
    • [ ] 🛠️ Bug fix (non-breaking change which fixes an issue)
    • [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change)
    • [x] 🧹 Code refactor
    • [x] ✅ Build configuration change
    • [x] 📝 Documentation
    • [x] 🗑️ Chore
    opened by RounakTadvi 1
  • Why is playStoreUrl removed?

    Why is playStoreUrl removed?

    Error: No named parameter with the name 'playStoreUrl'.

    If I go and look at your latest PR there I see that you completely removed this prop. Nothing is written about it, just deleted.

    opened by Milos5611 4
  • NativeUpdater.displayUpdateAlert default call update does not work

    NativeUpdater.displayUpdateAlert default call update does not work

    Using it like this: NativeUpdater.displayUpdateAlert( context, forceUpdate: true, );

    It displays the alert popup box but clicking update button does not affect anything. Tested with different iOS versions on physical devices and full production AppStore versions.

    opened by elmar001 1
Owner
Ofload
The next digital freight forwarding company
Ofload
react-native native module for In App Purchase.

Documentation Published in website. Announcement Version 8.0.0 is currently in release candidate. The module is completely rewritten with Kotlin and S

dooboolab 2.3k Dec 31, 2022
Flutter native ads - Show AdMob Native Ads use PlatformView

flutter_native_ads Flutter plugin for AdMob Native Ads. Compatible with Android and iOS using PlatformView. Android iOS Getting Started Android Androi

sakebook 64 Dec 20, 2022
dna, dart native access. A lightweight dart to native super channel plugin

dna, dart native access. A lightweight dart to native super channel plugin, You can use it to invoke any native code directly in contextual and chained dart code.

Assuner 14 Jul 11, 2022
A flutter deskstop package that allows you to drag the native file into app support.

FileDragAndDrop A flutter deskstop package that allows you to drag the native file into app support. Platform Support Now only support on macOS, if an

逸风 13 Oct 24, 2022
A flutter package uses native implementations to resize an image

fast_image_resizer This package uses native implementations to resize an image.

Soeren Schoenbrod 0 Dec 20, 2021
A Flutter package to make your text selectable for web and non-selectable for native builds.

PlatformText A Flutter package to make your text selectable for web and non-selectable for native builds. Features PlatformText returns Text or Select

Piotr Rozpończyk 1 Jun 9, 2022
A flutter package to cache network image fastly without native dependencies.

Fast Cached Network Image A flutter package to cache network image fastly without native dependencies, with loader, error builder, and smooth fade tra

CHRISTO 3 Sep 22, 2022
Mildly encrypted package - An encryption client & server for Dart Native + mobile platforms.

TODO: Put a short description of the package here that helps potential users know whether this package might be useful for them. Features TODO: List w

Andrew Stein 0 Jan 9, 2022
Code Snippets of highly interactive Flutter Templates that can be implemented in a Native Flutter App.

Native Frontend Flutter About the Repository We are on a mission to make things easy and convenient for all the users who just want to save their time

Dezenix 19 Sep 5, 2022
Create native settings for Flutter app in a minutes.

Settings UI for Flutter Installing: In your pubspec.yaml dependencies: settings_ui: ^1.0.1 import 'package:settings_ui/settings_ui.dart'; Basic Usag

Yako 716 Dec 29, 2022
Fluttersettingsui - Fork of settingsui. Create native settings for Flutter app in a minutes.

Settings UI for Flutter Installing: In your pubspec.yaml dependencies: flutter_settings_ui: ^1.0.1 import 'package:flutter_settings_ui/flutter_setti

Julian Steenbakker 22 Oct 24, 2022
This perfect starter kit is an app based on React Native and UI Kitten library with Light and Dark themes support.

Kitten Tricks This perfect starter kit is an app based on React Native and UI Kitten library with Light and Dark themes support. It’s completely free

Akveo 7k Dec 30, 2022
FlutterBoost is a Flutter plugin which enables hybrid integration of Flutter for your existing native apps with minimum efforts

中文文档 中文介绍 Release Note v3.0-preview.17 PS: Before updating the beta version, please read the CHANGELOG to see if there are any BREAKING CHANGE Flutter

Alibaba 6.3k Dec 30, 2022
Flutter Native Player for Flutter

Flutter Native Player for Flutter A Flutter plugin for Android, iOS for playing back video on a Widget surface. Installation Copy and paste to depende

Jane Roffer 6 Dec 15, 2022
A Sample Flutter project to show how to integrate native kotlin code with flutter

kotlin_flashlight A Sample Flutter project to show how to integrate native kotlin code with flutter. Getting Started Visit this docs for Flutter setup

null 0 Apr 4, 2022
Native Drag and Drop for Flutter on iOS and MacOS

native_draggable A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized package t

Rody Davis 59 Dec 4, 2022
A Flutter plugin for authenticating users by using the native TwitterKit SDKs on Android & iOS.

flutter_twitter_login A Flutter plugin for using the native TwitterKit SDKs on Android and iOS. This plugin uses the new Gradle 4.1 and Android Studio

Iiro Krankka 83 Sep 15, 2022
Allows send emails from flutter using native platform functionality.

flutter_email_sender Allows send emails from flutter using native platform functionality. In android it opens default mail app via intent. In iOS MFMa

Tautvydas Šidlauskas 107 Jan 3, 2023