Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add template local.properties file for the example app #68

Merged
merged 4 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 5 additions & 0 deletions example/android/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## This file must *NOT* be checked into Version Control Systems,
ajaysubra marked this conversation as resolved.
Show resolved Hide resolved
# as it contains information specific to your local configuration,
# such as your Klaviyo company ID aka "Public API Key".

#publicApiKey=YOUR_PUBLIC_API_KEY
Loading