Md *_*din 3 android google-play flutter in-app-update
我希望我的应用程序的用户始终拥有最新版本。如果他们没有最新版本,则应首先从 Play 商店下载最新版本,如图所示。
我找到了一个名为Upgrader的包,但这只是一个提示。如图所示,它没有链接到游戏商店。
编辑
正如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(),
);
},
);
}
}
Run Code Online (Sandbox Code Playgroud)
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 不提供此类功能。您可能想查看例如https://pub.dev/packages/upgrader。如果您在 iOS 设备上调用上述方法,您将遇到未实现的异常。
谢谢...
| 归档时间: |
|
| 查看次数: |
7074 次 |
| 最近记录: |