Fixed the restarting issue and now the app works and updates firebase even when it's in the background