Skip to content

Commit

Permalink
Update local.properties template files (#68)
Browse files Browse the repository at this point in the history
* Add template local.properties file to example app
* Be clearer about VCS status of these files.

---------

Co-authored-by: Evan Masseau <>
  • Loading branch information
evan-masseau committed Feb 2, 2024
1 parent 6208295 commit 13d871a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
9 changes: 5 additions & 4 deletions android/local.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## This file must *NOT* be checked into Version Control Systems,
## as it contains information specific to your local configuration
## Changes in this file must *NOT* be tracked by Version Control Systems,
# as it contains information specific to your local configuration.
# Only the base template should be checked in to VCS.

## Uncomment for local SDK development so that gradle can locate the
## correct RN version outside the context of an application
## Uncomment for local SDK development, so that gradle can locate the
# correct RN version outside the context of an application
#reactNativeAndroidVersion=0.73.1
8 changes: 8 additions & 0 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc:+'

android {
def localProperties = new Properties()
if (rootProject.file("local.properties").canRead()) {
localProperties.load(new FileInputStream(rootProject.file("local.properties")))
}
def apiKey = localProperties['publicApiKey'] ?: publicApiKey

ndkVersion rootProject.ext.ndkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion
Expand All @@ -93,13 +99,15 @@ android {
buildTypes {
debug {
signingConfig signingConfigs.debug
buildConfigField "String", "PUBLIC_API_KEY", "\"${apiKey}\""
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
buildConfigField "String", "PUBLIC_API_KEY", "\"${apiKey}\""
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MainApplication : Application(), ReactApplication {
override fun onCreate() {
super.onCreate()
SoLoader.init(this, false)
Klaviyo.initialize("YOUR_PUBLIC_API_KEY", this)
Klaviyo.initialize(BuildConfig.PUBLIC_API_KEY, this)
registerActivityLifecycleCallbacks(Klaviyo.lifecycleCallbacks)

if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
Expand Down
4 changes: 4 additions & 0 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ newArchEnabled=false
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true

# Public API Key for your Company
# or override this from an untracked local.properties file
publicApiKey=YOUR_PUBLIC_API_KEY
6 changes: 6 additions & 0 deletions example/android/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Changes in this file must *NOT* be tracked by Version Control Systems,
# as it contains information specific to your local configuration,
# such as your Klaviyo company ID aka "Public API Key".
# Only the base template should be checked in to VCS.

#publicApiKey=YOUR_PUBLIC_API_KEY

0 comments on commit 13d871a

Please sign in to comment.