Uploading Files to Firebase Storage in the Background

We’re trying to upload files to Firebase Storage when our App is in the Background.

We work on Unity App that runs on Android. We’ve created a plugin in Android Java, that works with custom service, connects and sends requests to the Firebase storage. This works when the app is in the foreground.

If we start the process (press a button) and put the App in the background, the process would start in the background but would stop when calling Firebase functionality. With all the prints shown on logcat till that point.

Only when moving the app back to the foreground, the process will continue, and the call to the Firebase functionality will execute. In other words - the scope of the OnSuccess handler would execute, and all the prints would show on the log.

What might prevent the calls to Firebase from executing when the app is in the background?

Here is the code called (On the android Service that is called and used by the plugin):

private void fbReadStorageTest(){
        mHandler.postDelayed(() -> {
            Log.d(TAG, "[SGA][BgUploadService][fbReadStorageTest]  - 10 -  Will be testing fb write here [2]... ");

            StorageReference storageReference = storeRef.child("/test");
            Log.d(TAG, "[SGA][BgUploadService][fbReadStorageTest] - 40 -About to read from: "+storageReference.getPath());           

            storageReference.listAll().addOnSuccessListener(new OnSuccessListener<ListResult>() {
                public void onSuccess(ListResult listResult) {
                    for (StorageReference item : listResult.getItems()) {
                        // Process each item in the list
                        // Here, you can access item properties like name, path, etc.
                        Log.d("StorageExample", "[SGA][BgUploadService][fbReadStorageTest] -  50.1 -  Item Name: " + item.getName());
                        Log.d("StorageExample", "[SGA][BgUploadService][fbReadStorageTest] -  50.3 - Item Path: " + item.getPath());

                    Log.d(TAG, "[SGA][BgUploadService][fbReadStorageTest] - Got List");

            }).addOnFailureListener(new OnFailureListener() {
                public void onFailure(@NonNull Exception e) {

                    Log.d(TAG, "[SGA][BgUploadService][fbReadStorageTest] - 140.4 - ListFiles  Failed "+e.getMessage());

        }, 5000);

Thanks, Shefy