我希望我的应用程序的用户总是有最新的版本。如果他们没有最新的版本,它应该先从play store下载最新版本,如图所示。
我发现了一个名为 升级器 但这只是给出了一个提示。它没有链接到播放商店,如图所示。
编辑
如上文所述 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安装 显示没有更新。
有什么办法可以解决这个问题吗?
有一个你想要的包。 https:/pub.devpackagesin_app_update。
安卓系统 本插件集成了官方的Android API,可以执行2019年发布的应用内更新。https:/developer.android.comguideapp-bundlein-app-updates。 iOS iOS不提供这样的功能。你可能想了解一下,例如 https:/pub.devpackagesupgrader。. 如果你在iOS设备上调用上述方法,你会遇到一个未实现的异常。
谢谢....