Flutter SDK

The App Upgrade Flutter SDK helps you to easily integrate with App Upgrade service. This SDK communicate with App Upgrade and check the version with version information in App Upgrade. Based on response it will:

  • If app needs force update will show a non-dismissable popup for update. On click it will launch app in app store for user to update.
  • If app needs to be updated but not a force update, it will show a dismissable popup.
  • If no action is required it won't do anything.

Installation

Install via npm

flutter pub add app_upgrade_flutter_sdk

How to use?

  • Follow the Getting Started guide to create project and get the x-api-key.

  • Import the SDK and use it.

import 'package:app_upgrade_flutter_sdk/app_upgrade_flutter_sdk.dart';
  • Integrate in your app.
import 'package:flutter/material.dart';
import 'package:app_upgrade_flutter_sdk/app_upgrade_flutter_sdk.dart';

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

class MyApp extends StatelessWidget {
  MyApp({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {

    AppInfo appInfo = AppInfo(
      appId: 'com.android.com' or '1549468967', // Your app id in play store or app store
      appName: 'Wallpaper app', // Your app name
      appVersion: '1.0.0', // Your app version
      platform: 'android', // App Platform, android or ios
      environment: 'production', // Environment in which app is running, production, staging or development etc.
      appLanguage: 'en' // App language ex: en, es etc. Optional.
    );

    return MaterialApp(
      title: 'App Upgrade Flutter Example',
      home: Scaffold(
          appBar: AppBar(
            title: Text('App Upgrade Flutter Example'),
          ),
          body: AppUpgradeAlert(
            xApiKey: 'ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5', // Your x-api-key
            appInfo: appInfo,
            child: Center(child: Text('Hello World!')),
          )
      ),
    );
  }
}

Note:

  1. For opening the app store or play store the app should be live.
  2. It might not be able to open the app store or play store in simulator. You can try it in physical device.
  3. If you are using the same code base for both android and ios than you can detect the platform and provide the appId.
  4. You can find a sample app from here app-upgrade-flutter-demo-app
  5. Read detailed blog on how to integrate from here How to upgrade/force upgrade Flutter app

Fields

  • appId: App Id of your app. Know how to find appId for your app. (Required)
  • appName: Your app name. (Required)
  • appVersion: Version of your app. (Required)
  • platform: This could be android or ios (Required)
  • environment: This could be for example development, int, production (Required)
  • appLanguage: This is your app language. Example: en, es etc. This will be used to localize the update message. (Optional)

Customizing the Alert popup

You can optionally pass the dialogConfig object to customize the alert popup.

  • dialogStyle: DialogStyle.material, // cupertino or material, default is material
  • title: Main title shown to user.
  • updateButtonTitle: Update button title shown to user.
  • laterButtonTitle: Later button title shown to user.

Example with Dialog Config

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

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

class MyApp extends StatelessWidget {
  MyApp({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {

    AppInfo appInfo = AppInfo(
      appId: 'com.android.com' or '1549468967', // Your app id in play store or app store
      appName: 'Wallpaper app',
      appVersion: '1.0.0',
      platform: 'android',
      environment: 'production',
      appLanguage: 'en' // App language ex: en, es etc. Optional.
    );

    DialogConfig dialogConfig = DialogConfig(
      dialogStyle: DialogStyle.material,
      title: 'App update required!',
      updateButtonTitle: 'Update Now',
      laterButtonTitle: 'Later'
      onUpdateCallback: () { print("Update callback") }
      onLaterCallback: () { print("Later callback") }
    );

    return MaterialApp(
      title: 'App Upgrade Flutter Example',
      home: Scaffold(
          appBar: AppBar(
            title: Text('App Upgrade Flutter Example'),
          ),
          body: AppUpgradeAlert(
            xApiKey: 'MmQwMDU3YWEtNmEzOC00NjQ4LThlYWItNWQ4YTI3YzZdfjdkfdkfdg5',
            appInfo: appInfo,
            dialogConfig: dialogConfig,
            child: Center(child: Text('Hello World!')),
          )
      ),
    );
  }
}

Redirect user to store other than app store or play store.

Supported Stores :
Apple App Store Google Play Store Amazon App Store Huawei AppGallery Other Android Markets
If your app market place isn't one of these you can pass your own store URL.

If you want users to redirect to store other than app store or playstore. You can add these additional parameters preferredAndroidMarket.

  • preferredAndroidMarket: PreferredAndroidMarket.amazon // or PreferredAndroidMarket.huawei or PreferredAndroidMarket.other If not provided default is Google playstore. If SDK fails to open preferred market place in case marketplace is not available then default Google playstore will be open.
  • otherAndroidMarketUrl: 'https://someotherandroidmarket.com/app/id'// Required if preferredAndroidMarket is Other.

Example:

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

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

class MyApp extends StatelessWidget {
  MyApp({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {

    AppInfo appInfo = AppInfo(
      appId: 'com.android.com' or '1549468967', // Your app id in play store or app store
      appName: 'Wallpaper app', // Your app name
      appVersion: '1.0.0', // Your app version
      platform: 'android', // App Platform, android or ios
      environment: 'production', // Environment in which app is running, production, staging or development etc.
      appLanguage: 'en' // App language ex: en, es etc. Optional.
      preferredAndroidMarket: PreferredAndroidMarket.amazon // or PreferredAndroidMarket.huawei or PreferredAndroidMarket.other If not provided default is Google playstore. Optional
      otherAndroidMarketUrl: 'https://someotherandroidmarket.com/app/id'// Required if preferredAndroidMarket is Other.
    );

    return MaterialApp(
      title: 'App Upgrade Flutter Example',
      home: Scaffold(
          appBar: AppBar(
            title: Text('App Upgrade Flutter Example'),
          ),
          body: AppUpgradeAlert(
            xApiKey: 'ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5', // Your x-api-key
            appInfo: appInfo,
            child: Center(child: Text('Hello World!')),
          )
      ),
    );
  }
}

For IOS, if you want to redirect user to some other store you can use the following parameters:

Callbacks

SDK provides two callbacks.

  1. onUpdateCallback onUpdateCallback callback is called when the user clicks on the Update button.

  2. onLaterCallback If the user clicks on the Later button the SDK will call the onLaterCallback. You can use these for tracking purposes or for something else. onLaterCallback can be used to set a timer and remind the user later that can be done from the app.

Debugging

You can provide debug true to enable debug logs

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

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

class MyApp extends StatelessWidget {
  MyApp({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {

    AppInfo appInfo = AppInfo(
      appId: 'com.android.com' or '1549468967', // Your app id in play store or app store
      appName: 'Wallpaper app', // Your app name
      appVersion: '1.0.0', // Your app version
      platform: 'android', // App Platform, android or ios
      environment: 'production', // Environment in which app is running, production, staging or development etc.
      appLanguage: 'en' // App language ex: en, es etc. Optional.
    );

    return MaterialApp(
      title: 'App Upgrade Flutter Example',
      home: Scaffold(
          appBar: AppBar(
            title: Text('App Upgrade Flutter Example'),
          ),
          body: AppUpgradeAlert(
            xApiKey: 'MmQwMDU3YWEtNmEzOC00NjQ4LThlYWItNWQ4YTI3YzZdfjdkfdkfdg5', // Your x-api-key
            appInfo: appInfo,
            debug: true, // You can specify debug true to print debug logs
            child: Center(child: Text('Hello World!')),
          )
      ),
    );
  }
}

Screenshots

Screenshot of alert - material

image

Screenshot of Cupertino alert

image

Force upgrade screenshot Example

Only update button is enable. User cannot skip it.

image

Changelog

Please see CHANGELOG for more information what has changed recently.

Need help?

If you're looking for help, please write to us at support@appupgrade.dev

© 2022-2023 | App Upgrade | All Rights Reserved            Updated 2023-10-23 19:38:41

results matching ""

    powered by algolia

    No results matching ""