微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

应用内更新不适用于封闭式测试轨道

如何解决应用内更新不适用于封闭式测试轨道

我已在封闭测试轨道上发布了我的应用。然后我对 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 举报,一经查实,本站将立刻删除。