Skip to content

Commit eef0c33

Browse files
github-actions[bot]evan-masseauajaysubrakennyklaviyodependabot[bot]
authored
Generated Docs for "Podfile and CI fixes (#120)* Use 1.14.3 pod version specifically" (#122)
* 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 <> * [CHNL-5370] Updating readme to include instructions on how to use `initialize` and `setToken` from RN code. (#113) * 0.1.1 * added troubleshooting * updated readme with initilize and set token instructions * adding notifee stuff to trouble shooting guide * removed duplicate android * removed package.json * some minor fixes * added example on requesting permission * Apply suggestions from code review Co-authored-by: Evan C Masseau <[email protected]> * minor updates * review comments * updated readme --------- Co-authored-by: Evan C Masseau <[email protected]> * Update to version 0.2.0 (#116) Update to v 0.2.0 Co-authored-by: Evan Masseau <> * Readme proofreading/formatting (#119) Co-authored-by: Evan Masseau <> * Podfile and CI fixes (#120) * Use 1.14.3 pod version specifically * Skip all caches if manually re executing CI --------- Co-authored-by: Evan Masseau <> * Generated docs for ad12079 --------- 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 843206d commit eef0c33

17 files changed

+266
-198
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ runs:
1212
- name: Cache dependencies
1313
id: yarn-cache
1414
uses: actions/cache@v4
15+
if: github.run_attempt == 1
1516
with:
1617
path: |
1718
**/node_modules

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
${{ runner.os }}-turborepo-android-
3333
3434
- name: Check turborepo cache for Android
35+
if: github.run_attempt == 1
3536
run: |
3637
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
3738
@@ -40,19 +41,19 @@ jobs:
4041
fi
4142
4243
- name: Install JDK
43-
if: env.turbo_cache_hit != 1 || ${{ github.run_attempt > 1 }}
44+
if: env.turbo_cache_hit != 1
4445
uses: actions/setup-java@v4
4546
with:
4647
distribution: 'zulu'
4748
java-version: '17'
4849

4950
- name: Finalize Android SDK
50-
if: env.turbo_cache_hit != 1 || ${{ github.run_attempt > 1 }}
51+
if: env.turbo_cache_hit != 1
5152
run: |
5253
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
5354
5455
- name: Cache Gradle
55-
if: env.turbo_cache_hit != 1 || ${{ github.run_attempt > 1 }}
56+
if: env.turbo_cache_hit != 1
5657
uses: actions/cache@v4
5758
with:
5859
path: |

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
${{ runner.os }}-turborepo-ios-
3838
3939
- name: Check turborepo cache for iOS
40+
if: github.run_attempt == 1
4041
run: |
4142
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
4243
@@ -45,7 +46,7 @@ jobs:
4546
fi
4647
4748
- name: Cache cocoapods
48-
if: env.turbo_cache_hit != 1
49+
if: env.turbo_cache_hit != 1 && github.run_attempt == 1
4950
id: cocoapods-cache
5051
uses: actions/cache@v4
5152
with:

Diff for: README.md

+92-91
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,17 @@ so you can import Android Klaviyo SDK references from your Kotlin/Java files wit
111111

112112
#### React Native 0.73.x
113113

114-
There are no additional installation requirements. Android support is fully tested and verified,
115-
including `minSdkVersion=23`.
114+
There are no additional installation requirements. Android support is fully tested and verified.
116115

117116
#### React Native 0.68.x - 0.72.x
118117

119118
We have successfully compiled the Klaviyo React Native SDK in a bare React Native template app for these versions
120119
with the following modifications to the `android/build.gradle` file:
121120

122-
- Set `compileSdkVersion=34`
123121
- Set `minSdkVersion=23`
122+
- Set `compileSdkVersion=34`
123+
124+
See [Android Troubleshooting](Troubleshooting.md#android-troubleshooting) for possible exceptions.
124125

125126
#### React Native <= 0.67.x
126127

@@ -138,20 +139,21 @@ Install [Cocoapods](https://cocoapods.org/) if you have not already.
138139
The SDK must be initialized with the short alphanumeric [public API key](https://help.klaviyo.com/hc/en-us/articles/115005062267#difference-between-public-and-private-api-keys1)
139140
for your Klaviyo account, also known as your Site ID.
140141

141-
Initialize _must_ be called prior to invoking any other SDK methods so that Klaviyo SDK can track profiles, events and push tokens toward the correct Klaviyo account.
142-
Any SDK operations invoked before initialize will be dropped, and result in a logged error.
142+
Initialize _must_ be called prior to invoking any other SDK methods so that Klaviyo SDK can track profiles, events and
143+
push tokens toward the correct Klaviyo account. Any SDK operations invoked before initialize will be dropped,
144+
and result in a logged error.
143145

144146
You can call `initialize` from your app's React Native layer or from the platform-specific native code.
145147
This decision is dependent on your app's architecture. It is not required to initialize the SDK in both places!
146-
Note: It is safe to re-initialize, e.g. if your app needs to connect to more than one Klaviyo account.
148+
Note: It is safe to re-initialize, e.g. if your app needs to switch between more than one Klaviyo account.
147149

148150
### React Native Initialization
149151

150152
Below is an example of how to initialize the SDK from your React Native code:
151153

152154
```typescript
153155
import { Klaviyo } from 'klaviyo-react-native-sdk';
154-
Klaviyo.initialize('YOUR_KLAVIYO_PUBLIC_API_KEY');
156+
Klaviyo.initialize('YOUR_PUBLIC_KLAVIYO_API_KEY');
155157
```
156158

157159
### Native Initialization
@@ -282,58 +284,56 @@ Refer to the following README sections on push setup:
282284

283285
### Collecting Push Tokens
284286

285-
Push tokens can be collected either from your app's react native code or in the native code. Below sections discuss both approaches, and
286-
you are free to pick one that best suits your app's architecture. Note that doing this in one location is sufficient.
287+
Push tokens can be collected either from your app's react native code or in the native code.
288+
Below sections discuss both approaches, and you are free to pick one that best suits your app's architecture.
289+
Note that doing this in one location is sufficient.
287290

288291
#### React Native Token Collection
289292

290293
In order to collect the APNs push token in your React Native code you need to:
291294

292-
1. Import a library such as [`@react-native-firebase/messaging`](https://www.npmjs.com/package/@react-native-firebase/messaging) to your react native project. The below instructions are specific for `@react-native-firebase/messaging` library.
293-
2. Import Firebase iOS SDK to your iOS project. Setup instructions can be found [here](https://firebase.google.com/docs/ios/setup).
294-
3. In order for the `UNUserNotificationCenter` delegate methods to be called in `AppDelegate`, method swizzling should be disabled for the Firebase SDK. For more information on this,
295-
please refer to the [Firebase documentation](https://firebase.google.com/docs/cloud-messaging/ios/client). Disabling method swizzling be done by adding the following to your `Info.plist`:
296-
297-
```xml
298-
<key>FirebaseAppDelegateProxyEnabled</key>
299-
<false/>
300-
```
301-
295+
1. Import a library such as [`@react-native-firebase/messaging`](https://www.npmjs.com/package/@react-native-firebase/messaging)
296+
to your react native project. The below instructions are specific for `@react-native-firebase/messaging` library.
297+
2. Import Firebase iOS SDK to your iOS project. Setup instructions can be found [here](https://firebase.google.com/docs/ios/setup).
298+
3. In order for the `UNUserNotificationCenter` delegate methods to be called in `AppDelegate`, method swizzling must be
299+
disabled for the Firebase SDK. For more information on this, please refer to the [Firebase documentation](https://firebase.google.com/docs/cloud-messaging/ios/client).
300+
Disable method swizzling by adding the following to your `Info.plist`:
301+
```xml
302+
<key>FirebaseAppDelegateProxyEnabled</key>
303+
<false/>
304+
```
302305
4. In `application:didRegisterForRemoteNotificationsWithDeviceToken:` method in your `AppDelegate.m` file, you can add the following code to set the push token to the firebase SDK:
303-
304-
```objective-c
305-
// since we disbaled swizzling, we have to manually set this
306-
FIRMessaging.messaging.APNSToken = deviceToken;
307-
```
308-
306+
```objective-c
307+
// since we disbaled swizzling, we have to manually set this
308+
FIRMessaging.messaging.APNSToken = deviceToken;
309+
```
309310
5. Finally, in your React Native code, you can collect & set the push token as follows:
310-
311-
```typescript
312-
import messaging from '@react-native-firebase/messaging';
313-
import { Klaviyo } from 'klaviyo-react-native-sdk';
314-
import { Platform } from 'react-native';
315-
316-
const fetchAndSetPushToken = async () => {
317-
try {
318-
let deviceToken: string | null = null;
319-
if (Platform.OS === 'android') {
320-
deviceToken = await messaging().getToken();
321-
console.log('FCM Token:', deviceToken);
322-
} else {
323-
deviceToken = await messaging().getAPNSToken();
324-
console.log('APNs Token:', deviceToken);
325-
}
326-
327-
if (deviceToken != null && deviceToken.length > 0) {
328-
Klaviyo.setPushToken(deviceToken!);
329-
}
330-
} catch (error) {
331-
console.error('Error in fetchAndSetPushToken:', error);
332-
}
333-
};
334-
```
335-
336-
For android token collection, there isn't any additional setup required on the native side. The above code should work as is.
311+
```typescript
312+
import messaging from '@react-native-firebase/messaging';
313+
import { Klaviyo } from 'klaviyo-react-native-sdk';
314+
import { Platform } from 'react-native';
315+
316+
const fetchAndSetPushToken = async () => {
317+
try {
318+
let deviceToken: string | null = null;
319+
if (Platform.OS === 'android') {
320+
deviceToken = await messaging().getToken();
321+
console.log('FCM Token:', deviceToken);
322+
} else {
323+
deviceToken = await messaging().getAPNSToken();
324+
console.log('APNs Token:', deviceToken);
325+
}
326+
327+
if (deviceToken != null && deviceToken.length > 0) {
328+
Klaviyo.setPushToken(deviceToken!);
329+
}
330+
} catch (error) {
331+
console.error('Error in fetchAndSetPushToken:', error);
332+
}
333+
};
334+
```
335+
336+
For Android token collection, there isn't any additional setup required on the native side. The above code should work as is.
337337

338338
#### Native Token Collection
339339

@@ -344,49 +344,50 @@ Follow the platform-specific instructions below:
344344

345345
#### Notification Permission
346346

347-
Requesting user permission to display notifications can be managed in:
348-
349-
1. The native layer as instructed in our native SDK documentation,
350-
351-
- [Android](https://github.com/klaviyo/klaviyo-android-sdk#collecting-push-tokens)
352-
- [iOS](https://github.com/klaviyo/klaviyo-swift-sdk?tab=readme-ov-file#request-push-notification-permission)
353-
354-
If you requested permission using native code then continue using Klaviyo's native platform SDKs `setToken` method to inform the SDK of permission change.
347+
Requesting user permission to display notifications can be managed from the React Native code, or from platform-specific
348+
native code. Note that either of these approaches is sufficient to inform the Klaviyo SDK of the permission change.
355349

356-
2. Leveraging a third party library that provides cross-platform permissions APIs like firebase [`react-native-firebase/messaging`](https://www.npmjs.com/package/@react-native-firebase/messaging). If you opt for a
357-
cross-platform permission solution, you can now call the Klaviyo's react native SDK's `setToken` method to refresh the token's enablement status.
350+
1. **React Native Notification Permission**:
351+
You can leverage a third party library that provides cross-platform permissions APIs like firebase [`react-native-firebase/messaging`](https://www.npmjs.com/package/@react-native-firebase/messaging).
352+
If you opt for a cross-platform permission solution, call the Klaviyo React Native SDK's `setToken` method to refresh
353+
the token's enablement status.
358354

359355
Below is an example of how to use `@react-native-firebase/messaging` to request permission and set the token:
360356

361-
```typescript
362-
import messaging from '@react-native-firebase/messaging';
363-
364-
const requestUserPermission = async () => {
365-
let isAuthorized = false;
366-
367-
if (Platform.OS === 'android') {
368-
const androidAuthStatus = await PermissionsAndroid.request(
369-
PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS
370-
);
371-
isAuthorized = androidAuthStatus === 'granted';
372-
} else if (Platform.OS === 'ios') {
373-
const iOsAuthStatus = await messaging().requestPermission();
374-
isAuthorized =
375-
iOsAuthStatus === messaging.AuthorizationStatus.AUTHORIZED ||
376-
iOsAuthStatus === messaging.AuthorizationStatus.PROVISIONAL;
377-
}
378-
379-
// refer the `fetchAndSetPushToken` method from the previous section for how to get and set the push token
380-
381-
if (isAuthorized) {
382-
console.log('User has notification permissions enabled.');
383-
} else {
384-
console.log('User has notification permissions disabled');
385-
}
386-
};
387-
```
357+
```typescript
358+
import messaging from '@react-native-firebase/messaging';
359+
360+
const requestUserPermission = async () => {
361+
let isAuthorized = false;
362+
363+
if (Platform.OS === 'android') {
364+
const androidAuthStatus = await PermissionsAndroid.request(
365+
PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS
366+
);
367+
isAuthorized = androidAuthStatus === 'granted';
368+
} else if (Platform.OS === 'ios') {
369+
const iOsAuthStatus = await messaging().requestPermission();
370+
isAuthorized =
371+
iOsAuthStatus === messaging.AuthorizationStatus.AUTHORIZED ||
372+
iOsAuthStatus === messaging.AuthorizationStatus.PROVISIONAL;
373+
}
374+
375+
// refer the `fetchAndSetPushToken` method from the previous section for how to get and set the push token
376+
377+
if (isAuthorized) {
378+
console.log('User has notification permissions enabled.');
379+
} else {
380+
console.log('User has notification permissions disabled');
381+
}
382+
};
383+
```
384+
2. **Native Notification Permission**:
385+
Follow instructions from our native SDK documentation to request permission from native code:
386+
- [Android](https://github.com/klaviyo/klaviyo-android-sdk#collecting-push-tokens)
387+
- [iOS](https://github.com/klaviyo/klaviyo-swift-sdk?tab=readme-ov-file#request-push-notification-permission)
388388

389-
Note that either one of the above approaches is sufficient to inform the Klaviyo SDK of the permission change.
389+
If you requested permission using native code then continue using Klaviyo's native platform SDKs `setToken`
390+
method to inform the SDK of permission change.
390391

391392
### Receiving Push Notifications
392393

@@ -449,7 +450,7 @@ Linking.getInitialURL().then((url) => {
449450

450451
## Troubleshooting
451452

452-
Use the [troubleshooting guide](Troubeshooting.md) to resolve common issues with the Klaviyo React Native SDK.
453+
Use the [troubleshooting guide](Troubleshooting.md) to resolve common issues with the Klaviyo React Native SDK.
453454
If the issues you are facing isn't in the troubleshooting guide, and you believe it's a bug in the SDK, please file an issue in our repository.
454455

455456
## Contributing

Diff for: Troubleshooting.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Troubleshooting Guide
2+
3+
## Android Troubleshooting
4+
5+
### `minSdkVersion` Issues
6+
We have seen projects, particularly on react-native versions `0.72.x` and `0.71.x`, that required a `minSdkVersion`
7+
of `24`, despite the Klaviyo Android SDK supporting API 23+. If you encounter this, please file an issue in our
8+
repository and provide version numbers of your react-native dependencies.
9+
10+
## iOS Troubleshooting
11+
12+
### CocoaPods Installation Issues
13+
14+
1. If you are seeing issues related to `minimum deployment target` when installing pods, you may need to update your
15+
minimum iOS version to 13.0 in your Podfile with one of the following strategies:
16+
17+
- Specify iOS version directly in the `Podfile`:
18+
```ruby
19+
MIN_IOS_OVERRIDE = '13.0'
20+
if Gem::Version.new(MIN_IOS_OVERRIDE) > Gem::Version.new(min_ios_version_supported)
21+
min_ios_version_supported = MIN_IOS_OVERRIDE
22+
end
23+
# existing code
24+
platform :ios, min_ios_version_supported
25+
```
26+
- Set the deployment target to 13.0 in XCode, and then pull `IPHONEOS_DEPLOYMENT_TARGET` from the XCode project:
27+
```ruby
28+
#######
29+
# Read min iOS version from Xcode project and set as min iOS version for Podfile
30+
require 'xcodeproj'
31+
32+
project_path = './YOUR_XCODE_PROJECT.xcodeproj'
33+
project = Xcodeproj::Project.open(project_path)
34+
min_ios_version_supported = project.build_configurations.first.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
35+
######
36+
37+
platform :ios, min_ios_version_supported
38+
```
39+
40+
2. If the command `pod install` is outputting version mismatch errors for `KlaviyoSwift`, please
41+
run `pod update KlaviyoSwift` as indicated in the error message to update your local pods spec repo.
42+
43+
### `UNUserNotificationCenter` delegate methods not being called
44+
45+
If you are not seeing the delegate methods for `UNUserNotificationCenter` being called in `AppDelegate`,
46+
there are two possible reasons for this:
47+
48+
1. [Notifee](https://notifee.app/) intercepts the AppDelegate delegate methods and hence you may not receive
49+
the delegate calls if notifee is included in the iOS project. The solution is to remove notifee dependency
50+
from your project or exclude it for iOS.
51+
2. Firebase iOS SDK also swizzles AppDelegate methods when configured on your iOS app. If after disabling notifee,
52+
if the delegates are still not called, this may be the reason. Method swizzling can be turned off by following
53+
[Firebase's documentation](https://firebase.google.com/docs/cloud-messaging/ios/client).

0 commit comments

Comments
 (0)