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

一, auto_updater 

SDK:FLUTTER

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

需要分别在 macOS 和 Windows 系统中运行该命令。

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

本示例中 macOS 和 Windows 使用同一个 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版本更新

相关内容

热门资讯

六分钟了解透视挂脚本!微乐小程... 六分钟了解透视挂脚本!微乐小程序免费黑科技,微乐内蒙麻将透视挂多功能法子APP1、玩家可以在微乐小程...
一分钟了解辅助挂资料!百乐科技... 一分钟了解辅助挂资料!百乐科技多功能辅助挂脚本,百乐科技原来真的是有辅助脚本1、进入到百乐科技是否有...
一分钟带你了解透视器插件!AA... 一分钟带你了解透视器插件!AAPoKer多功能透视器插件,AAPoKer其实存在有透视器插件亲,关键...
分享认知开挂工具!微乐小程序免... 分享认知开挂工具!微乐小程序免费黑科技,微乐够级开挂多功能指南APP1、微乐小程序免费黑科技辅助软件...
分享一款辅助挂要领!棋趣联盟多... 分享一款辅助挂要领!棋趣联盟多功能辅助挂攻略,棋趣联盟果然确实有辅助攻略1、在棋趣联盟插件功能辅助器...
一分钟了解辅助技巧!红龙pok... 一分钟了解辅助技巧!红龙poker多功能辅助技巧,红龙poker一直有辅助技巧红龙poker破解侠是...
最新技巧开挂脚本!微信微乐小程... 最新技巧开挂脚本!微信微乐小程序有挂黑科技,微乐捉麻子开挂多功能机巧APP1、该软件可以轻松地帮助玩...
必备攻略辅助挂课程!快玩炸翻天... 必备攻略辅助挂课程!快玩炸翻天多功能辅助挂app,快玩炸翻天果然是真的有辅助app1、快玩炸翻天有没...
一分钟揭秘作弊器教程!德扑圈多... 一分钟揭秘作弊器教程!德扑圈多功能作弊器教程,德扑圈总是真的是有作弊器教程1、下载好德扑圈正确养号方...
玩家必看科普辅助器神器!微乐小... 玩家必看科普辅助器神器!微乐小程序免费黑科技,微乐邵阳麻将辅助器多功能讲义APP进入游戏-大厅左侧-...