0

I have tried to isolate the problem- on my main page, I added this code to test.

void deleteMe() {
    FirebaseDatabase.instance
        .reference()
        .child(
        "users")
        .onValue
        .listen((Event user) {
          print("user = " + user.snapshot.value.toString());
    }).onData((Event event) {
      print("Event = $event");
    });
  }

  @override
  void initState() {
    deleteMe();
    _ensureLoggedIn();
    super.initState();
  }

If I run flutter run -d --release, and update a user's information in the database, log messages are only shown when I am in the app. When I leave the app, and then change values in my firebase database, I see no log messages- but when I open the app again they are printed. This is not the case when I run in debug mode.

This is all for iOS so far.

Why does my listener stop listening when I leave the app, only in release mode?

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
Andrew Takao
  • 105
  • 1
  • 13
  • Hi, as far as I know, background execution in iOS requires permissions that Apple just doesn't give away easily - few apps have it. Search for background execution with flutter, there is a component that might help you. – Feu Sep 30 '18 at 06:58
  • I guess my confusion is why it only works for debug-- I looked for background execution with flutter, it doesn't seem to be ready. Right now, I'm trying to find ways to use my debug build as a release build... I have no idea if this stands a chance of working, do you have any advice on that? – Andrew Takao Oct 02 '18 at 17:53
  • Debug - Apple will never let you publish that! :) They manually test each app and prohibit tags like 'debug', 'test mode', etc. If it's an app only for yourself, then go for it and install directly from the computer in the devices - I think it's up to a 100 devices. – Feu Oct 03 '18 at 14:17

0 Answers0