HomeiOS Developmentios - Firebase Flutter Refresh subject

ios – Firebase Flutter Refresh subject


I’ve a stay Flutter App that makes use of firebase Datastore.

  • When the consumer is logged out and I make modifications to the consumer doc and the consumer logs again within the modifications I’ve made within the firestore database keep. ( Right perform )

  • When the consumer is logged in and utilizing the app and I make modifications to the consumer doc the modifications I’ve made within the firestore database keep. ( Right perform )

  • ** When the consumer is logged in and backgrounds the app through the use of one other app or locking the cellphone and I make modifications to the consumer doc then the consumer resumes the app the info I’ve modified within the consumer doc reverts to the outdated knowledge. ** ( incorrect perform ) this solely occurs on an actual gadget and never and emulator.

What’s the subject I’ve tried incorporating this code in the principle then i attempted incorporating it in different screens of the app. Despatched to check flight and subject remains to be current.


@override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    tremendous.didChangeAppLifecycleState(state);
    if (state == AppLifecycleState.resumed) {
      userState.refreshUserData();
      topicsManager();
      print('App resumed - refreshing knowledge');
    }
  } 


  @motion
  Future<void> refreshUserData() async {
    strive {
      print('Refreshing consumer knowledge...');

      closing docSnapshot = await FirebaseFirestore.occasion
          .assortment(USERS_COLLECTION)
          .doc(docId) // Guarantee 'docId' is appropriately set
          .get(GetOptions(
              supply: Supply.server)); 

      if (docSnapshot.exists) {
        Map<String, dynamic> latestUserData =
            docSnapshot.knowledge() as Map<String, dynamic>;
        Map<String, dynamic> latestUserBeeInfo =
            latestUserData['beeInfo'] as Map<String, dynamic>;
        String? latestBeeType = latestUserBeeInfo['beeType'];

        // Immediately evaluate needed fields or make the most of a technique if complicated logic is required
        // For simplicity, assuming direct discipline checks right here:
        if (me.displayName != latestUserData['displayName'] ||
            me.e mail != latestUserData['email'] ||
            me.userBeeInfoField.beeType != latestBeeType) {
          loadUser(latestUserData, docId);
          print('Consumer knowledge up to date with recent knowledge.');
        } else {
          print('No modifications in consumer knowledge detected.');
        }
      } else {
        print('Consumer knowledge doc doesn't exist.');
      }
    } catch (e) {
      print('Error refreshing consumer knowledge: $e');
    }
  }

What's the subject I've tried incorporating this code in the principle then i attempted incorporating it in different screens of the app. Despatched to check flight and subject remains to be current.  

 @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    tremendous.didChangeAppLifecycleState(state);
    if (state == AppLifecycleState.resumed) {
      userState.refreshUserData();
      topicsManager();
      print('App resumed - refreshing knowledge');
    }
  } 


  @motion
  Future<void> refreshUserData() async {
    strive {
      print('Refreshing consumer knowledge...');

      closing docSnapshot = await FirebaseFirestore.occasion
          .assortment(USERS_COLLECTION)
          .doc(docId) // Guarantee 'docId' is appropriately set
          .get(GetOptions(
              supply: Supply.server)); 

      if (docSnapshot.exists) {
        Map<String, dynamic> latestUserData =
            docSnapshot.knowledge() as Map<String, dynamic>;
        Map<String, dynamic> latestUserBeeInfo =
            latestUserData['beeInfo'] as Map<String, dynamic>;
        String? latestBeeType = latestUserBeeInfo['beeType'];

        // Immediately evaluate needed fields or make the most of a technique if complicated logic is required
        // For simplicity, assuming direct discipline checks right here:
        if (me.displayName != latestUserData['displayName'] ||
            me.e mail != latestUserData['email'] ||
            me.userBeeInfoField.beeType != latestBeeType) {
          loadUser(latestUserData, docId);
          print('Consumer knowledge up to date with recent knowledge.');
        } else {
          print('No modifications in consumer knowledge detected.');
        }
      } else {
        print('Consumer knowledge doc doesn't exist.');
      }
    } catch (e) {
      print('Error refreshing consumer knowledge: $e');
    }
  } 

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments