본문 바로가기
Flutter

[Flutter] Upgrader 사용법

by hymndaniel 2023. 5. 10.

Motivation

앱을 업데이트하고 나서 사용자가 빠르게 업데이트하도록 유도하고 싶을때

 

Upgrader패키지 사용

Upgrader 패키지는 앱을 시작할때 appcast를 사용하여 앱의 최신 버전 정보를 가져와 비교한 후 필요시 업데이트 알림을 실행한다.

이를 위해 먼저 appcast.xml을 준비해야한다. 

appcast.xml 예시 

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
  <channel>
    <title>앱 이름</title>
    <!-- Android updates -->
    <item>
      <title>Version 새로운 버전번호</title>
      <description>설명&#10;단락 나누고설명
      </description>
      <pubDate>Tue, 10 May 2023 00:00:00 -0700</pubDate>
      <enclosure url="출시된 구글플레이스토어 주소"
                 sparkle:version="새로운 버전번호" sparkle:os="android" />
    </item>

    <!-- iOS updates -->
    <item>
      <title>Version 새로운 버전번호</title>
      <description>설명&#10;단락 나누고설명
      </description>
      <pubDate>Tue, 10 May 2023 00:00:00 -0700</pubDate>
      <enclosure url="출시된 앱스토어 주소"
                 sparkle:version="새로운 버전번호" sparkle:os="ios" />
    </item>
  </channel>
</rss>

이 파일을 Github에 올려주고 raw 주소를 가져온다.

'https://raw.githubusercontent.com/larryaasen/upgrader/master/test/testappcast.xml'

 

다음으로 코드에서 반영한다.

https://pub.dev/packages/upgrader/install

 

upgrader | Flutter Package

Flutter package for prompting users to upgrade when there is a newer version of the app in the store.

pub.dev

import 'package:upgrader/upgrader.dart';

upgrader를 실행할 위치에서 사용하면 된다.

lass MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // Upgrader
    const appcastURL =
        'https://raw.githubusercontent.com/~~/appcast.xml';
    final cfg =
        AppcastConfiguration(url: appcastURL, supportedOS: ['android', 'ios']);

    return UpgradeAlert(
      upgrader: Upgrader(
      	// debugDisplayAlways: true //개발할때 시뮬레이터에서 보여줌
        // debugLogging: true // 버전 정보 등 디버그 콘솔에서 보여줌
        shouldPopScope: () => true,
        dialogStyle: GetPlatform.isIOS
            ? UpgradeDialogStyle.cupertino
            : UpgradeDialogStyle.material,
        appcastConfig: cfg,
      ),
      child: FutureBuilder(
        future: SecureStorage.getJwt(),
        builder: (context, AsyncSnapshot snapshot) {
          if (snapshot.hasData == false) {
            return Scaffold(
              body: Center(
                child: ...

 

Reference

https://github.com/larryaasen/upgrader

 

GitHub - larryaasen/upgrader: A Flutter package for prompting users to upgrade when there is a newer version of the app in the s

A Flutter package for prompting users to upgrade when there is a newer version of the app in the store. - GitHub - larryaasen/upgrader: A Flutter package for prompting users to upgrade when there i...

github.com

https://morioh.com/p/5dab319ebb44

 

Flutter package for prompting users to upgrade

Upgrader .Flutter package for prompting users to upgrade when there is a newer version of the app in the store.

morioh.com

https://smile-develop.tistory.com/entry/Flutter-Upgrader-package-%EC%82%AC%EC%9A%A9%ED%95%B4%EB%B3%B4%EA%B8%B0-2

 

Flutter Upgrader package 사용해보기 - 2

appcast.xml을 github를 올리셨으면 이제 코드를 수정하시면 됩니다!!. https://pub.dev/packages/upgrader Upgrader Package를 추가해주세요! upgrader | Flutter Package Flutter package for prompting users to upgrade when there is a newer

smile-develop.tistory.com

 

728x90

'Flutter' 카테고리의 다른 글

[Flutter] vscode dart formatter  (0) 2023.05.24
[Flutter] lint / linter  (0) 2023.05.24
[Flutter] scroll listView with index  (0) 2023.05.09
[Flutter] network image with JWT header  (0) 2023.05.04
[Flutter] ListTile의 leading 사이즈 고정하기  (0) 2023.05.04