Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Google Firebase Remote Config without Google Play Services?

Is it possible to use Firebase Remote Config without having Google Play Services installed (aosp) on the device?

I did follow this setup in my android project: (via https://firebase.google.com/docs/android/setup):

  1. added classpath 'com.google.gms:google-services:4.3.3' into main gradle file
  2. added implementation 'com.google.firebase:firebase-config:19.1.3' and 'apply plugin: 'com.google.gms.google-services'' into app gradle file

It does compile, but when I initially start the app fetchAndActivate does not succeed, because task results with after calling fetch():

MISSING_INSTANCEID_SERVICE (Failed to get Firebase Instance ID token for fetch)

  firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
        FirebaseRemoteConfigSettings.Builder configBuilder = new FirebaseRemoteConfigSettings.Builder();
        configBuilder.setMinimumFetchIntervalInSeconds(3600);


        firebaseRemoteConfig.setConfigSettingsAsync(configBuilder.build());
        HashMap<String, Object> defaults = new HashMap<>();
        defaults.put("variant", "basic");
        startActivity(new Intent(getApplicationContext(), CarLauncherBasic.class));

        firebaseRemoteConfig.setDefaultsAsync(defaults);
        firebaseRemoteConfig.fetchAndActivate()
                .addOnCompleteListener(this, new OnCompleteListener<Boolean>() {
                    @Override
                    public void onComplete(@NonNull Task<Boolean> task) {
                        if (task.isSuccessful()) {
                            boolean updated = task.getResult();
                            Toast.makeText(MainActivity.this, "Fetch and activate succeeded",
                                    Toast.LENGTH_SHORT).show();

                        } else {
                            Toast.makeText(MainActivity.this, "Fetch failed",
                                    Toast.LENGTH_SHORT).show();
                        }
                        String variant = firebaseRemoteConfig.getString("variant");

//
                    }
                });

    }
like image 968
icouldin Avatar asked Mar 18 '20 14:03

icouldin


People also ask

Is Firebase remote config free?

Firebase Remote Config is part of the Firebase platform and is available for free on both iOS and Android.

Is Firebase remote config safe?

Using Firebase's Remote Config is hardly more secure than shipping keys in the app bundle. Either way, the data ends up on users' hardware. A malicious person can then theoretically access it, no matter how difficult we may think that is to do.

How do I get data from Firebase remote config?

Getting started Run the sample on an Android device or emulator. Change one or more parameter values in the Firebase Console (the value of welcome_message , welcome_message_caps , or both). Tap Fetch Remote Config in the app to fetch new parameter values and see the resulting change in the app.


1 Answers

firebaser here

Firebase Remote Config no longer depends on Google Play Services, and can be used on any Android installation.

For an up to date list of what Firebase services work without Play services, see Dependencies of Firebase Android SDKs on Google Play services in the Firebase documentation.

Previous answer that was outdated:

Unfortunately Remote Config currently depends on having Google Play services installed on the device.

The dependency is indirect though, and transitive, which is why I (actually: we, as multiple folks went down this same rabbit hole) initially overlooked it.

The good news is that many Firebase services are moving to a newer service called Firebase Installation Service, which no longer depends on Google Play services. But there's no timeline for when Remote Config will no longer have that dependency.

Previous answer that was wrong 😞:

I asked around, and it seems that Remote Config does not depend on Google Play Services on the device. So you should be able to use it on an AOSP device.

However, a lot of use-cases for Remote Config depend on targeting users based on Analytics events and properties. And since Analytics is not part of Firebase's open-source SDKs, you won't be able to target users on AOSP with Analytics properties. The other targeting capabilities of Remote Config will work for everyone, but you'll only be able to target users based on Analytics events/properties if they are on a device with Google Play Services.

like image 65
Frank van Puffelen Avatar answered Oct 09 '22 05:10

Frank van Puffelen