flutter 版本自动更新调研
创始人
2025-01-07 21:04:17
0

一, auto_updater 

SDKFLUTTER

PLATFORM:MACOSWINDOWS

This plugin allows Flutter desktop apps to automatically update themselves (based on sparkle and winsparkle).

许可证 : MIT

Sparkle

Sparkle的原理是根据提前配置好的xml文件地址,每次启动后解析xml,看看有没有比当前版本新的数据,有的话提示更新。 xml文件可以存在任何可以访问xml元数据的服务器,包括 GitHub 仓库。

详细接入教程:macOS 使用 Sparkle 检查软件自更新

CocoaPods的安装与使用_cocoapods安装_ailinghao的博客-CSDN博客

winsparkle

是一个Windows的App更新框架,它是一个Windows下应用程序的即插即忘的软件升级库。

该库容易使用以及发布,WinSparkle.dll没有任何额外的依赖(甚至没有动态CRT)。只需要包含该文件即可,并且它的API都是C语言形式的,可以用任何语言来使用它。

工具包以及语言依赖:WinSparkle的UI使用本地Windows控制器的且它是在单独的线程中运行的,因此不用担心和自己所选择的GUI工具(wxWidgets,QT,WinForms,WPF等)产生兼容性问题。

win_sparkle_set_appcast_url:为应用程序设置URL,只支持http以及https格式。关于URL地址可参考此链接获取更多信息。

实例:win_sparkle_set_appcast_url("https://raw.githubusercontent.com/LibreVR/Revive/master/appcast.xml")

win_sparkle_set_can_shutdown_callback:设置回调函数用来查询应用程序是否可以结束。在尝试启动安装程序前,该回调会被调用以询问host是否准备好关闭。若host应用程序能够安全结束,则该回调返回TRUE;反之为FALSE。

详细接入教程

auto_updater 快速开始

集成sdk

将此添加到你的软件包的 pubspec.yaml 文件:

dependencies: auto_updater: ^0.1.7

dependencies: auto_updater: git: url: https://github.com/leanflutter/auto_updater.gitref: main

⚠️ Windows requirements
  • openssl

运行以下命令:

使用 Chocolatey

 

choco install openssl

用法

import 'package:auto_updater/auto_updater.dart'; void main() async {

// 必须加上这一行。

WidgetsFlutterBinding.ensureInitialized(); String feedURL = 'http://localhost:5002/appcast.xml'; await autoUpdater.setFeedURL(feedURL); await autoUpdater.checkForUpdates(); await autoUpdater.setScheduledCheckInterval(3600); runApp(MyApp()); }

请看这个插件的示例应用,以了解完整的例子。

发布你的应用

生成私钥

运行以下命令:

dart run auto_updater:generate_keys

需要分别在 macOSWindows 系统中运行该命令。

macOS

准备使用 EdDSA 签名算法进行签名:

输出:

 

A key has been generated and saved in your keychain. Add the `SUPublicEDKey` key to the Info.plist of each app for which you intend to use Sparkle for distributing updates. It should appear like this: SUPublicEDKey pfIShU4dEXqPd5ObYNfDBiQWcXozk7estwzTnF9BamQ=

更改文件 macos/Runner/Info.plist 如下:

... + SUPublicEDKey

+ bHaXClrRGMmKoKP/3HJnr/jn2ODTRPAM3VZhhkI9ZvY=

Windows

准备使用 DSA 签名算法进行签名:

输出:

 

Generated two files: dsa_priv.pem: your private key. Keep it secret and don't share it! dsa_pub.pem: public counterpart to include in youe app. BACK UP YOUR PRIVATE KEY AND KEEP IT SAFE! If you lose it, your users will be unable to upgrade!

命令将为你生成私钥(dsa_priv.pem)及公钥(dsa_pub.pem),请备份你的私钥并确保其安全,并将公钥作为 Windows 资源添加到项目中。

更改文件 windows/runner/Runner.rc 如下:

... +/

+//

+// WinSparkle

+//

+// And verify signature using DSA public key:

+DSAPub DSAPEM "../../dsa_pub.pem"

打包应用

为了简化打包的过程,这里使用了 Flutter Distributor ,一个专门用于打包和发布 Flutter 应用的完整工具。

distribute_options.yaml 添加到你的项目根目录。

output: dist/releases: - name: devjobs: - name: release-macospackage: platform: macostarget: zipbuild_args: dart-define: APP_ENV: dev

# 查看完整文档:https://distributor.leanflutter.org/configuration/makers/exe - name: release-windowspackage: platform: windowstarget: exebuild_args: dart-define: APP_ENV: dev

macOS

运行以下命令:

 

flutter_distributor release --name dev --jobs release-macos

Windows

运行以下命令:

 

flutter_distributor release --name dev --jobs release-windows

获取签名
macOS

运行以下命令:

 

dart run auto_updater:sign_update dist/1.1.0+2/auto_updater_example-1.1.0+2-macos.zip

输出:

 

sparkle:edSignature="pbdyPt92pnPkzLfQ7BhS9hbjcV9/ndkzSIlWjFQIUMcaCNbAFO2fzl0tISMNJApG2POTkZY0/kJQ2yZYOSVgAA==" length="13400992"

将获得的新签名更新到 appcast.xml 文件 enclosure 节点的 sparkle:edSignature 属性值。

Windows

运行以下命令:

 

dart run auto_updater:sign_update dist/1.1.0+2/auto_updater_example-1.1.0+2-windows-setup.exe

输出:

 

sparkle:dsaSignature="MEUCIQCVbVzVID7H3aUzAY5znpi+ySZKznkukV8whlMFzKh66AIgREUGOmvavlcg6hwAwkb2o4IqVE/D56ipIBshIqCH8rk=" length="13400992"

将获得的新签名更新到 appcast.xml 文件 enclosure 节点的 sparkle:dsaSignature 属性值。

分发应用

appcast.xml 添加到你的项目 dist/ 目录。

auto_updater_example Most recent updates to auto_updater_example en Version 1.1.0 https://your_domain/your_path/release_notes.html Sun, 16 Feb 2022 12:00:00 +0800 Version 1.1.0 https://your_domain/your_path/release_notes.html Sun, 16 Feb 2022 12:00:00 +0800

本示例中 macOSWindows 使用同一个 appcast.xml 文件,你需根据配置 sparkle:os 属性的值。

启动测试更新服务器:

 

cd dist/ serve -l 5002

故障排除

macOS
  • 确保按照 Sparkle 文档中的说明添加了 sparkle pod

  • 通过将以下内容添加到您的授权文件以进行调试和发布,确保您已添加并启用应用程序的网络功能并禁用沙箱以进行发布

 

com.apple.security.network.client com.apple.security.network.server com.apple.security.app-sandbox

API

AutoUpdater

Methods

setFeedURL

设置 url 并初始化 auto updater.

checkForUpdates

检查更新,在此之前必须先调用 setFeedURL.

setScheduledCheckInterval

设置检查时间间隔,默认 86400,最少 3600, 设置为0 代表不更新

二, flutter_autoupdate 1.0.0 

This library allows you to easily add auto-update functionality to your Android, iOS, and Windows Flutter application.

SDK: FLUTTER

PLATFORM: ANDROID. IOS Windows

许可证 : BSD-3-Clause license

三, flutter_xupdate

cloud.tencent.com

PLATFORM: ANDROID. IOS

A Flutter plugin for XUpdate -- Android Update Library。See the use Chinese Document for details。

flutter_xupdate 让你一键实现flutter应用版本更新

Flutter XUpdate 是否支持苹果iOS版本更新

相关内容

热门资讯

带你了解“雀友会钻石辅助器潮汕... 带你了解“雀友会钻石辅助器潮汕麻将”一贯存在有挂(辅助挂)详细辅助2025教程1、玩家可以在软件透明...
透视中牌率!闲来辅助神器怎么下... 透视中牌率!闲来辅助神器怎么下载,心悦辅助,2025新版技巧(有挂技巧)科技教程也叫必备教程,这是一...
第二分钟辅助!蜀渝牌乐汇辅助(... 第二分钟辅助!蜀渝牌乐汇辅助(辅助挂)本然存在有挂(详细辅助大神讲解);小薇(透视辅助)致您一封信;...
第三分钟辅助(浙江宝宝游戏辅助... 第三分钟辅助(浙江宝宝游戏辅助器哪里能下载)其实是真的有挂(详细辅助2025教程)1、浙江宝宝游戏辅...
玩家爆料“手机游戏辅助器”真是... 玩家爆料“手机游戏辅助器”真是是真的有挂(辅助挂)详细辅助必胜教程;1、下载好辅助软件之后点击打开,...
透视ai代打!约逗东乡k105... 透视ai代打!约逗东乡k105辅助工具,情怀宜春辅助,必备教程(有挂透明);大神普及一款德州ai内幕...
六分钟辅助!微信新财神辅助(辅... 六分钟辅助!微信新财神辅助(辅助挂)都是是真的有挂(详细辅助wpk教程)是一款可以让一直输的玩家,快...
第五分钟辅助(斗棋有bug吗)... 第五分钟辅助(斗棋有bug吗)竟然存在有挂(详细辅助实用技巧)1、全新机制【斗棋有bug吗软件透明挂...
玩家必看科普“微乐小程游戏破解... 玩家必看科普“微乐小程游戏破解器下载”果然存在有挂(辅助挂)详细辅助必赢教程是一种具有地方特色的麻将...
透视计算!新荣耀辅助软件,约局... 透视计算!新荣耀辅助软件,约局吧辅助器,科技教程(有挂教程);支持2-10人实时对战,虚拟庄家发牌,...