Hi All,
I am trying to use the React Native SDK in my app, primarily to register push tokens to a user’s Klaviyo profile. I have been unable to achieve this. The code runs without error, but no tokens ever show up on the user’s profile.
As a test, I also tried using the SDK to generate a custom event. This also did not seem to work (it did not show up on the user’s profile).
Here is the code I am using:
import { Klaviyo } from 'klaviyo-react-native-sdk';
Klaviyo.initialize(MY_SITE_KEY);
if (userData.klaviyoID) {
Klaviyo.setProfile({
id: userData.klaviyoID,
});
} else if (userData.email) {
Klaviyo.setEmail(userData.email);
Klaviyo.setExternalId(userData.uid);
}
// Neither of the above approaches works.
...
Klaviyo.setPushToken(TOKEN_RECEIVED_FROM_FCM);
Klaviyo.createEvent({
name: 'My Custom Event',
});As a temporary workaround, I have been calling the Klaviyo REST API to register push tokens, which works fine. But because using the SDK directly to register push tokens or create events doesn’t work, I am concerned that other functionality which relies on the SDK (e.g. tracking notification clicks) is also not going to work.
There is code not shown in the excerpt above that gets the token from FCM. It knows to get an APNs token if the app is running on iOS and an FCM token if it’s running on Android. But that shouldn’t matter. In theory, you should be able to pass any string to the setPushToken method, and it should show up in the user’s profile. That’s how the Klaviyo REST API behaves.
Is there anything obvious that I’m doing wrong? I have been working at this for a couple of days, and I’m pretty much stumped.

