How to unregister Apptentive in Android?

147 views Asked by At

I need to disable Apptentive from showing its feedback dialogs because it is interfering with my UI tests. I could not find any method to unregister or disable it. I tried setting random app key like this, but apptentive is using the cached API key.

@BeforeClass
public static void beforeClass() {
  Apptentive.register(CustomApp.getInstance(), "");
}
1

There are 1 answers

0
Sky Kelsey On BEST ANSWER

You can't unregister Apptentive after it has been registered, but there are a few ways to keep it from showing up when you run your UI tests.

  1. Use a special build variant for your UI tests. Then, in Application.onCreate(), wrap the call to Apptentive.register() in a check against the build config flavor

    @Override
    onCreate() {
      if (!BuildConfig.FLAVOR.equals("<YOUR_UI_TEST_FLAVOR>")) {
        Apptentive.register(...);
      }
    }
    
  2. You can set a piece of Custom Person Data like Apptentive.addCustomPersonData("ui_test", true). Then, use that in your Interaction "Who" criteria so that the Interaciton can't show as long as this flag is true.