Skip to content

Commit 8c12b00

Browse files
github-actions[bot]evan-masseauajaysubrakennyklaviyodependabot[bot]
authored
Generated Docs for "Bridge initialize and setPushToken to RN layer (#98)*"
* Link to license file in README (#60) Co-authored-by: Evan Masseau <> * Updated readme to include troubleshooting steps when running pod install (#63) updated readme * Updating version to 0.1.1 (#66) * 0.1.1 * updating version * reverting back to use older rn version * updating yarn lock * removing changes to package lock file * Fixes for React Native Apps <= 0.72.0 (#71) * Fix the react-native gradle dependency * Add a local property to enable specifying react-native version for the SDK for local development * Specify Kotlin version that is compatible with Android SDK's (although this didn't seem to actually cause any build errors) * Remove accidental use of an extension method that is technically SDK 24+ --------- Co-authored-by: Evan Masseau <> * Update local.properties template files (#68) * Add template local.properties file to example app * Be clearer about VCS status of these files. --------- Co-authored-by: Evan Masseau <> * Bump example iOS project lockfile (#74) I think this needs to be bumped when we increase the overall project version. Co-authored-by: Evan Masseau <> * Github CI Updates (#75) * Move doc bot to its own file so we don't have to see it as skipped all the time. * Use same ruby version as local dev environment * Stop using `yarn pod-install` because it creates an erroneous xcode.env.local file that breaks the hermes build scripts. --------- Co-authored-by: Evan Masseau <> * Updating to iOS SDK 3.0.2 (#77) * 0.1.1 * updated to us latest iOS SDK * removing package lock * Pod install | static linking issue | RCT Folly | Turbo modules (#70) * 0.1.1 * removed turbo module stuff and added xcconfig * removing package lock * comitting example app pod lock file --------- Co-authored-by: Evan Masseau <> Co-authored-by: Evan C Masseau <[email protected]> * Readme rewrite with references to native SDKs and Klaviyo help center (#62) --------- Co-authored-by: Evan Masseau <> Co-authored-by: Kenny Tsui <[email protected]> * Release 0.1.2 (#84) * 0.1.1 * Release 0.1.2 * removed package lock * podlock file changes * Break up CI files so we can get individual badges (#86) * Break up CI files so we can get individual badges * Add badges and fix names --------- Co-authored-by: Evan Masseau <> * Add action to publish to NPM after publishing a release (#82) --------- Co-authored-by: Evan Masseau <> * Update README.md (#90) * Publish to NPM with the default npm registry configured in package.json (#92) --------- Co-authored-by: Evan Masseau <> * Updated iOS instructions in example app (#99) * 0.1.1 * udpate the example app to implement push * hanlded deep links * removed package json lock file * updated to addressed Evan comments in the pr * Fix mistaken duplicate open push section (#95) Co-authored-by: Evan Masseau <> * Remove local.properties from git index (#96) * remove local.properties from git index, changes were still being tracked despite gitignore * missed variable --------- Co-authored-by: Evan Masseau <> * Update README.md (#105) * Update README.md * Update README.md * Implemented deep links to call react native in example iOS app (#104) * 0.1.1 * implemented deep linking calls to react native * removed unused method * removed package lock * added deep linking hanlder * [CHNL-5592] Adding troubleshooting guide linked from readme (#109) * 0.1.1 * added troubleshooting * removed packagfe lock * added troibleshoting to the contents * swapped android and ios * [Dependabot] Bump ip from 1.1.8 to 1.1.9 (#111) Bumps [ip](https://github.com/indutny/node-ip) from 1.1.8 to 1.1.9. - [Commits](indutny/node-ip@v1.1.8...v1.1.9) --- updated-dependencies: - dependency-name: ip dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add example app instructions to README, make use of Gemfile (#97) * To make proper use of bundle, lockfile needs to be committed. I specified a cocoapods version since podfile.lock contains cocoapods version! Add explicit instructions about example app * Added alias for entire example app setup script Try updating CI step to use gem to pin cocoapods version --------- Co-authored-by: Evan Masseau <> * Bridge initialize and setPushToken to RN layer (#98) * Add an initialize method to react native layer * Add set push token to RN layer * Updated to latest versions of native SDKs * Elaboration on example app initialize/setPushToken, use a consistent value for example API key * SCREAMING_SNAKE_CASE --------- Co-authored-by: Evan Masseau <> * Generated docs for a44a582 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Evan C Masseau <[email protected]> Co-authored-by: Ajay Subramanya <[email protected]> Co-authored-by: Kenny Tsui <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions <[email protected]>
1 parent 6cc0fb7 commit 8c12b00

33 files changed

+356
-105
lines changed

Diff for: .github/actions/setup/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ runs:
2222
${{ runner.os }}-yarn-
2323
2424
- name: Install dependencies
25-
if: steps.yarn-cache.outputs.cache-hit != 'true'
25+
if: steps.yarn-cache.outputs.cache-hit != 'true' || ${{ github.run_attempt > 1 }}
2626
run: yarn install --immutable
2727
shell: bash

Diff for: .github/workflows/android-ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ jobs:
4040
fi
4141
4242
- name: Install JDK
43-
if: env.turbo_cache_hit != 1
43+
if: env.turbo_cache_hit != 1 || ${{ github.run_attempt > 1 }}
4444
uses: actions/setup-java@v4
4545
with:
4646
distribution: 'zulu'
4747
java-version: '17'
4848

4949
- name: Finalize Android SDK
50-
if: env.turbo_cache_hit != 1
50+
if: env.turbo_cache_hit != 1 || ${{ github.run_attempt > 1 }}
5151
run: |
5252
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
5353
5454
- name: Cache Gradle
55-
if: env.turbo_cache_hit != 1
55+
if: env.turbo_cache_hit != 1 || ${{ github.run_attempt > 1 }}
5656
uses: actions/cache@v4
5757
with:
5858
path: |

Diff for: README.md

+60-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ We are actively testing and expanding support to the latest patch releases of re
6868

6969
- Minimum Deployment Target `13.0+`
7070

71-
## Installation
71+
The Klaviyo React Native SDK allows developers to incorporate Klaviyo analytics and push notification functionality in
72+
their React Native applications for Android and iOS. It is a Typescript wrapper (native module bridge) around the native
73+
Klaviyo iOS and Android SDKs. For more information on the native SDKs, please see the
74+
[iOS](https://github.com/klaviyo/klaviyo-swift-sdk) and [Android](https://github.com/klaviyo/klaviyo-android-sdk).
75+
repositories. This repo also contains a basic [React Native sample app](./example) to assist your integration.
7276

7377
The Klaviyo React Native SDK is available via [NPM](http://npmjs.com). To add it to your project,
7478
run the following from your project's root directory:
@@ -121,6 +125,61 @@ We are actively working to verify compatibility with these versions. If you enco
121125
After installing the npm package, run the following command in the `ios` directory of your React Native project.
122126
Install [Cocoapods](https://cocoapods.org/) if you have not already.
123127

128+
### React Native
129+
130+
## Initialization
131+
132+
The SDK must be initialized with the short alphanumeric
133+
[public API key](https://help.klaviyo.com/hc/en-us/articles/115005062267#difference-between-public-and-private-api-keys1)
134+
for your Klaviyo account, also known as your Site ID. Initialization is done in the native layer, and must occur before
135+
any other SDK methods can be invoked. Follow the native SDK instructions for initialization, and refer to the
136+
[example app](./example) in this repository for guidance:
137+
138+
- [Android SDK instructions](https://github.com/klaviyo/klaviyo-android-sdk#Initialization), and
139+
[example app `MainApplication.kt`](./example/android/app/src/main/java/com/klaviyoreactnativesdkexample/MainApplication.kt#L39)
140+
- [iOS SDK instructions](https://github.com/klaviyo/klaviyo-swift-sdk#Initialization), and
141+
[example app `AppDelegate.mm`](./example/ios/KlaviyoReactNativeSdkExample/AppDelegate.mm#L14)
142+
143+
### Example App
144+
We have included a bare-bones example app in this repository for reference of how to integrate with our SDK.
145+
It is primarily intended to give code samples such as how and where to `initialize` or how to implement notification
146+
delegate methods on iOS. To actually run the example app:
147+
- Clone this repository
148+
- From the root directory, run `yarn example-setup`. This is an alias that will do the following:
149+
- Run `yarn install --immutable` from the root directory
150+
- Navigate to the `example` directory and run `bundle install`
151+
- Navigate to the `example/ios` directory and run `bundle exec pod install`
152+
- From the project's root directory, run `yarn example start` to start the example application. Follow the
153+
metro instructions from here, i.e. press `i` to run on iOS or `a` to run on Android.
154+
155+
### Android
156+
157+
Android installation requirements may vary depending upon your project configuration and other dependencies.
158+
The Klaviyo React Native SDK's `build.gradle` file exposes transitive dependencies upon the Klaviyo Android SDK,
159+
so you can import Android Klaviyo SDK references from your Kotlin/Java files without modifying your gradle configuration.
160+
161+
#### React Native 0.73.x
162+
163+
There are no additional installation requirements. Android support is fully tested and verified,
164+
including `minSdkVersion=23`.
165+
166+
#### React Native 0.68.x - 0.72.x
167+
168+
We have successfully compiled the Klaviyo React Native SDK in a bare React Native template app for these versions
169+
with the following modifications to the `android/build.gradle` file:
170+
171+
- Set `compileSdkVersion=34`
172+
- Set `minSdkVersion=23`
173+
174+
#### React Native <= 0.67.x
175+
176+
We are actively working to verify compatibility with these versions. If you encounter issues, please file an issue.
177+
178+
### iOS
179+
180+
After installing the npm package, run the following command in the `ios` directory of your React Native project.
181+
Install [Cocoapods](https://cocoapods.org/) if you have not already.
182+
124183
#### React Native 0.68.x - 0.72.x
125184
We have successfully compiled the Klaviyo React Native SDK in a bare React Native template app for these versions
126185
with the following modifications to the `android/build.gradle` file:

Diff for: android/build.gradle

+3-2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ repositories {
102102
google()
103103
}
104104

105+
def klaviyoAndroidSdkVersion = getExtOrDefault("klaviyoAndroidSdkVersion")
105106
def kotlin_version = getExtOrDefault("kotlinVersion")
106107
def localProperties = new Properties()
107108
if (rootProject.file("local.properties").canRead()) {
@@ -126,8 +127,8 @@ dependencies {
126127
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
127128

128129
// Klaviyo Android SDK
129-
api "com.github.klaviyo.klaviyo-android-sdk:analytics:2.0.0"
130-
api "com.github.klaviyo.klaviyo-android-sdk:push-fcm:2.0.0"
130+
api "com.github.klaviyo.klaviyo-android-sdk:analytics:$klaviyoAndroidSdkVersion"
131+
api "com.github.klaviyo.klaviyo-android-sdk:push-fcm:$klaviyoAndroidSdkVersion"
131132

132133
// We used reflection to enumerate keywords in the Klaviyo Android SDK dynamically
133134
implementation "org.jetbrains.kotlin:kotlin-reflect:1.8.21"

Diff for: android/gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro
1111
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1212
# org.gradle.parallel=true
1313
#Tue Dec 19 15:08:27 EST 2023
14+
KlaviyoReactNativeSdk_klaviyoAndroidSdkVersion=2.1.0
1415
KlaviyoReactNativeSdk_compileSdkVersion=31
1516
KlaviyoReactNativeSdk_kotlinVersion=1.8.0
1617
KlaviyoReactNativeSdk_minSdkVersion=23

Diff for: android/src/main/java/com/klaviyoreactnativesdk/KlaviyoReactNativeSdkModule.kt

+16
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ class KlaviyoReactNativeSdkModule internal constructor(private val context: Reac
4545
}
4646
}
4747

48+
@ReactMethod
49+
override fun initialize(apiKey: String) {
50+
Klaviyo.initialize(apiKey, context)
51+
}
52+
4853
@ReactMethod
4954
override fun setProfile(profile: ReadableMap) {
5055
val parsedProfile = Profile()
@@ -57,6 +62,7 @@ class KlaviyoReactNativeSdkModule internal constructor(private val context: Reac
5762
parsedProfile[key] = value
5863
}
5964
}
65+
6066
else ->
6167
if (value is Serializable) {
6268
parsedProfile[key] = value
@@ -110,6 +116,16 @@ class KlaviyoReactNativeSdkModule internal constructor(private val context: Reac
110116
Klaviyo.resetProfile()
111117
}
112118

119+
@ReactMethod
120+
override fun setPushToken(token: String) {
121+
Klaviyo.setPushToken(token)
122+
}
123+
124+
@ReactMethod
125+
override fun getPushToken(callback: Callback) {
126+
callback.invoke(Klaviyo.getPushToken())
127+
}
128+
113129
@ReactMethod
114130
override fun createEvent(event: ReadableMap) {
115131
val klaviyoEvent =

Diff for: android/src/oldarch/KlaviyoReactNativeSdkSpec.kt

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import com.facebook.react.bridge.ReadableMap
77

88
abstract class KlaviyoReactNativeSdkSpec internal constructor(context: ReactApplicationContext) :
99
ReactContextBaseJavaModule(context) {
10+
abstract fun initialize(apiKey: String)
11+
1012
abstract fun setProfile(profile: ReadableMap)
1113

1214
abstract fun setExternalId(externalId: String)
@@ -28,5 +30,9 @@ abstract class KlaviyoReactNativeSdkSpec internal constructor(context: ReactAppl
2830

2931
abstract fun resetProfile()
3032

33+
abstract fun setPushToken(token: String)
34+
35+
abstract fun getPushToken(callback: Callback)
36+
3137
abstract fun createEvent(event: ReadableMap)
3238
}

Diff for: docs/assets/search.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)