Leanplum / Leanplum-Android-SDK

Leanplum's integrated solution delivers meaningful engagement across messaging and the in-app experience.
https://www.leanplum.com
Apache License 2.0
46 stars 40 forks source link

Provide app keys from xml file #414

Closed hborisoff closed 4 years ago

hborisoff commented 4 years ago
What Where/Who
JIRA Issue SDK-36
People Involved @hborisoff

Background

This PR adds functionality to provide app keys by xml file.

Implementation

If client hasn't set the app keys before calling Leanplum.start they are loaded from Android string resources.

You can provide them by creating app/src/main/res/values/leanplum-app.xml containing:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <string name="leanplum_app_id">APP_ID</string>
  <string name="leanplum_prod_key">PROD_KEY</string>
  <string name="leanplum_dev_key">DEV_KEY</string>
  <!-- Environment is 'production' or 'development' -->
  <string name="leanplum_environment">ENVIRONMENT</string>
</resources>

Note that using another approach like external file (json or xml) adds a lot of complication to the codebase because you must do all I/O operations on a background thread but Leanplum.start is running partially on the UI thread.