【发布时间】:2020-09-19 13:50:09
【问题描述】:
我希望我的应用的用户始终拥有最新版本。如果他们没有最新版本,它应该首先从 Play 商店下载最新版本,如图所示。
我找到了一个名为Upgrader 的包,但这只是提示。如图所示,它没有链接到 Play 商店。
编辑
正如 Maadhav Sharma 所建议的,我现在正在使用 in_app_update 软件包,但它显示 没有可用的更新。
这是我的代码:
....
class _TnPState extends State<TnP> {
ThemeBloc _themeBloc;
FirebaseMessaging _firebaseMessaging;
NotificationBloc _notificationBloc;
String _test;
@override
void initState() {
_themeBloc = ThemeBloc();
_firebaseMessaging = FirebaseMessaging();
_notificationBloc = NotificationBloc();
_firebaseMessaging.configure(
onMessage: (notification) async => _notificationBloc.yes(),
onResume: (notification) async => _notificationBloc.yes(),
onLaunch: (notification) async => _notificationBloc.yes(),
);
checkForUpdate();
super.initState();
}
Future<void> checkForUpdate() async {
InAppUpdate.checkForUpdate().then((info) {
String display = info.toString();
setState((){
_test = display;
});
});
}
@override
Widget build(BuildContext context) {
return StreamBuilder<AppTheme>(
stream: _themeBloc.themeStream,
initialData: AppTheme.Light,
builder: (context, AsyncSnapshot<AppTheme> snapshot) {
return MaterialApp(
title: 'TnP',
debugShowCheckedModeBanner: false,
theme: appThemeData[snapshot.data],
home: _test==null ?
Container() :
InAppUpdateScreen(display: _test),//SplashScreen(),
);
},
);
}
}
InAppUpdateScreen 只显示文本。
应用商店显示更新可用:
但是通过 Playstore 安装的旧版本应用没有显示更新:
知道如何解决这个问题吗?
【问题讨论】:
-
我不知道如何,但第二天它开始工作了!我猜可能是 Playstore 出了问题。
-
你能分享一下它的完整代码吗?我也对强制更新应用程序感到困扰。它没有给我任何可用的更新。
-
除非您在我的应用和游戏部分看到可用更新,否则它不会检测到更新。
标签: android flutter google-play in-app-update