问题描述
我已在封闭测试轨道上发布了我的应用。然后我对 UI 进行了更改并在同一轨道上发布了更新,但是当我打开我的应用程序时,我仍然看到旧版本的 UI。当我访问Play商店时,有一个更新按钮。但是,我希望我的应用程序强制更新。我已经等了 9 个小时,但我仍然没有得到更新的版本。
这是我的代码:
AndroidNotificationChannel channel;
FlutterlocalnotificationsPlugin FlutterlocalnotificationsPlugin;
final GlobalKey<NavigatorState> navigatorKey = GlobalKey(debugLabel: "Main Navigator");
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
RemoteNotification notification = message.notification;
FlutterlocalnotificationsPlugin.show(
notification.hashCode,notification.title,notification.body,NotificationDetails(
android: AndroidNotificationDetails(
channel.id,channel.name,channel.description,icon: '@drawable/splash',playSound: true
),));
navigatorKey.currentState
.push(MaterialPageRoute(builder: (_) => OrdeRSScreen()));
}
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
channel = const AndroidNotificationChannel(
'high_importance_channel',// id
'High Importance Notifications',// title
'This channel is used for important notifications.',// description
importance: Importance.high,);
FlutterlocalnotificationsPlugin = FlutterlocalnotificationsPlugin();
await FlutterlocalnotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterlocalnotificationsPlugin>()
?.createNotificationChannel(channel);
await DotEnv.load(fileName: ".env");
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
var _isLoading;
var appUpdate;
void initState(){
super.initState();
checkForUpdate();
var initializationSettingsAndroid = AndroidInitializationSettings('@drawable/splash');
var initializationSettings = InitializationSettings(android:initializationSettingsAndroid);
FlutterlocalnotificationsPlugin.initialize(initializationSettings);
FirebaseMessaging.instance
.getinitialMessage()
.then((RemoteMessage message) {
if (message != null) {
navigatorKey.currentState
.push(MaterialPageRoute(builder: (_) => OrdeRSScreen()));
}
});
FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
print('Inside onmessage');
RemoteNotification notification = message.notification;
AndroidNotification android = message.notification?.android;
if (notification != null && android != null) {
FlutterlocalnotificationsPlugin.show(
notification.hashCode,));
AwesomeDialog(
context: navigatorKey.currentContext,dismissOnTouchOutside:false,dialogType: DialogType.SUCCES,animType: AnimType.TOPSLIDE,title: 'You have received a new order',desc: notification.body,btnCancelOnPress: () {
},btnOkText: "Go to Orders",btnCancelText:"Cancel",btnOkOnPress: () {
setState(() {
navigatorKey.currentState
.push(MaterialPageRoute(builder: (_) => OrdeRSScreen()));
});
}
)..show();
}
});
}
AppUpdateInfo _updateInfo;
Future<void> checkForUpdate() async {
setState(() {
_isLoading = true;
});
InAppUpdate.checkForUpdate().then((info) {
setState(() {
_updateInfo = info;
appUpdate = _updateInfo?.updateAvailable;
if(appUpdate)
InAppUpdate.performImmediateUpdate()
.catchError((e) => print(e.toString()));
print('End of app update code');
});
}).catchError((e) => print(e.toString()));
setState(() {
_isLoading = false;
});
}
@override
Widget build(BuildContext context) {
var isopen = false;
DateTime Now = DateTime.Now();
String formattedTime = DateFormat.Hm().format(Now);
print(formattedTime);
if(formattedTime.toString().compareto('09:00') >= 0 && formattedTime.toString().compareto('23:00') <= 0 )
{
print('inside isopen');
isopen = true;
}
return !(_isLoading)?MultiProvider(
providers: [
ChangeNotifierProvider(
create: (_) => Auth(),),ChangeNotifierProxyProvider<Auth,Products>(
create:null,update:(ctx,auth,prevIoUsProducts) => Products(auth.token,auth.userId)),ChangeNotifierProvider(
create: (_) => Cart(),ChangeNotifierProvider(
create: (_) => ColorChanger(),],//The consumer ensures that the material app gets built whenever Auth object changes
child: Consumer<Auth>(builder: (ctx,_) =>
MaterialApp(
navigatorKey: navigatorKey,title: 'dmd',theme: ThemeData(
textTheme: Theme.of(context).textTheme.apply(
bodyColor: Colors.black,displayColor: Colors.black,primaryColor: Colors.white,accentColor: Color(0xFFF2AD18),fontFamily: 'Muli',home:
auth.isAuth?
CategoriesScreen()
: FutureBuilder(
future: auth.tryAutoLogin(),builder: (ctx,authResultSnapshot) =>
authResultSnapshot.connectionState ==
ConnectionState.waiting
? Center(
child: Loading(),)
: LoginPage(),// home: PersonalInfoScreen(),routes: {
omeScreen.routeName: (ctx) => NavigationHomeScreen()
}
),)
):Center(child:Loading());
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)