我希望我的应用程序的用户始终拥有最新版本。如果他们没有最新版本,则应如图所示首先从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
只显示文字。
Play商店中的应用显示更新可用:
但是该应用是通过playstore安装的较旧版本,没有更新:
任何想法如何解决这个问题?
有一个您想要的软件包:https :
//pub.dev/packages/in_app_update
Android
此插件集成了官方Android API以在2019年发布的应用程序更新中执行:https : //developer.android.com/guide/app-bundle/in-app-updates
iOS
iOS iOS不提供此类功能。您可能要研究例如https://pub.dev/packages/upgrader。如果在iOS设备上调用上述方法,则会遇到未实现的异常。
谢谢...
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句