problem at the first launch RemoteConfig with conditions
Asked Answered
D

2

5

I am facing an issue with the RemoteConfig param which has conditions. Most of the time, I get the default value at the first app open. After that, I get the other condition values. My conditions are User in random percentile from 0 -> 10, 10 -> 20, 20 -> 30,...., 90 -> 100. As my opinion, it's should never be the default value (because the conditions cover 100% of user percentile). I did call fetchAndActive() and call mFirebaseRemoteConfig.getString() after task.isSuccessful(). Any idea?

Deccan answered 8/5, 2019 at 10:18 Comment(0)
D
1

after a lot of days on searching, but there's no clue about it, I had to do a dirty, tricky method to solve my issue: fetch and load the remote config after 1s on onCreate:

Observable.timer(1, TimeUnit.SECONDS)
                    .observeOn(AndroidSchedulers.mainThread())
                    .doOnNext(time ->{
                        fetchAndActiveRemoteConfig();
                    })
                    .subscribe();

P/s: it works but I dont know why it works.

Deccan answered 23/5, 2019 at 16:28 Comment(2)
I am facing the same issue please help me to solve it out. this was not helping me out.Diffuser
I've tried so many workarounds and only this one workedTrafalgar
F
5

I faced the same issue more than a week ago and after some googling the only similar thing I found was this question. Today I finally found the reason and implemented simple workaround. Long story short there is a race condition in Firebase SDK initialization connected to 'FirebaseInstanceId' generation: during initial launch Firebase does remote config request before generating AppInstanceId. Because of this backend is not able to apply some conditions related to remote params, like 'user in random percentile'. To fix this we need to generate app instance id before initializing the SDK. So the code may look like this:

FirebaseInstanceId.getInstance().getInstanceId()
    .addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
    @Override
    public void onComplete(@NonNull Task<InstanceIdResult> task) {
        //init firebase remote config here
    }
});

Hope this will help.

Folliculin answered 23/5, 2019 at 16:9 Comment(0)
D
1

after a lot of days on searching, but there's no clue about it, I had to do a dirty, tricky method to solve my issue: fetch and load the remote config after 1s on onCreate:

Observable.timer(1, TimeUnit.SECONDS)
                    .observeOn(AndroidSchedulers.mainThread())
                    .doOnNext(time ->{
                        fetchAndActiveRemoteConfig();
                    })
                    .subscribe();

P/s: it works but I dont know why it works.

Deccan answered 23/5, 2019 at 16:28 Comment(2)
I am facing the same issue please help me to solve it out. this was not helping me out.Diffuser
I've tried so many workarounds and only this one workedTrafalgar

© 2022 - 2024 — McMap. All rights reserved.