zetakit_reactnative
v1.0.0
Published
Zeta Global React Native SDK
Downloads
19,645
Maintainers
Readme
Zeta Global React Native SDK
The Zeta React Native plugin enables developers to integrate Zeta's services seamlessly into React Native applications. It provides a simple, reliable, and efficient way to access Zeta APIs and build robust cross-platform apps for iOS and Android.
Key Offerings
- User Identification: Manage user profiles, contact details, and custom attributes.
- Event Tracking: Track custom user actions and behaviors.
- Push Notification Handling: Register device tokens, receive and process push notifications.
- In-App Messaging: Display rich, contextual in-app messages to users.
- App Inbox: Retrieve, read, and manage in-app inbox messages.
- Opt-in/out Controls: Support user privacy with tracking opt-in/opt-out preferences.
SDK Support & Compatibility
- React Native: Version
0.76.0and above. - iOS: Minimum deployment target iOS 15.1+.
- Android: Minimum supported version Android 7.0 (API level 24).
Installation
Install the plugin in your React Native project using npm or yarn:
# Using npm
npm install zetakit_reactnative
# Using yarn
yarn add zetakit_reactnativeiOS Setup
After installing the package, install the required CocoaPods:
cd ios && pod install && cd ..Note: Ensure your iOS project's deployment target is set to iOS 15.1 or higher.
Android Setup
Ensure your Android project has Google Play Services and Firebase Messaging configured if you are using push notifications. Set the minSdkVersion to 24 or higher in your android/app/build.gradle file.
Quick Start & Usage
1. Initialization
Initialize the Zeta SDK as early as possible in your application lifecycle (e.g., in App.tsx or your index file).
import ZetaClient, {
ZTRegion,
ZTAppEnvironment,
type ZTConfig,
} from 'zetakit_reactnative';
const config: ZTConfig = {
clientSiteId: 'your_client_site_id',
clientSecret: 'your_client_secret',
region: ZTRegion.US,
appGroupId: 'your_app_group_id', // iOS only
optIn: true,
appEnvironment: ZTAppEnvironment.PRODUCTION,
};
ZetaClient.initialize(config, () => {
console.log('Zeta SDK initialized successfully');
});2. Setting User Details
Identify users and update their profiles with custom attributes.
import ZetaClient, { type ZTUserEmailContact } from 'zetakit_reactnative';
ZetaClient.user.build((user) => {
user.uid = 'user_unique_id';
user.firstName = 'John';
user.lastName = 'Doe';
const emailContact: ZTUserEmailContact = {
email: '[email protected]',
additionalInfo: {}
};
user.email = emailContact;
// Set custom properties
user.additionalProperties = {
'membership_level': 'gold',
'preferred_language': 'en'
};
});3. Event Tracking
Track custom events to understand user behavior.
import ZetaClient from 'zetakit_reactnative';
ZetaClient.events.track('purchase_completed', {
'item_id': 'sku_12345',
'price': 99.99,
'currency': 'USD'
});4. App Inbox
Retrieve and manage messages in the user's App Inbox.
import ZetaClient from 'zetakit_reactnative';
// Fetch all inbox messages
const messages = await ZetaClient.inbox.getMessages();
// Mark a message as read
await ZetaClient.inbox.markAsRead(messageId);
// Delete a message
await ZetaClient.inbox.deleteMessage(messageId);
// Get unread message count
const unreadCount = await ZetaClient.inbox.getUnreadCount();5. Push Notification Management
Update Device Token
Send the push token to Zeta to target the device.
import ZetaClient from 'zetakit_reactnative';
ZetaClient.user.updateDeviceToken('your_device_token');Handle Push Notifications (iOS Only)
Process incoming push notification payloads.
import ZetaClient from 'zetakit_reactnative';
const handled = await ZetaClient.push.handleNotificationsMessage(
response,
actionIdentifier, // optional; iOS falls back to UNNotificationDefaultActionIdentifier
);
if (handled) {
completionHandler();
}Note: On Android, handleNotificationsMessage resolves to false so shared JS code does not need platform guards.
Native Push Configurations
- iOS: Native iOS setup is required to configure push notifications. Refer to the Zeta iOS SDK Push Documentation for details.
- Android: If your application does not use a custom service, the SDK automatically captures the device token. If you override the default push channel behavior, configure the channel in your
Application.onCreatemethod. Refer to the Zeta Android SDK Push Documentation for details.
Controlling Log Level
Use ZTLogger.setLogLevel(...) to control the verbosity of native SDK logs. Call it before ZetaClient.initialize(...) to capture startup logs.
import ZetaClient, { ZTLogger, ZTLogLevel } from 'zetakit_reactnative';
ZTLogger.setLogLevel(ZTLogLevel.DEBUG);
ZetaClient.initialize(config, () => {
console.log('SDK initialized with DEBUG logging');
});Available log levels: NONE (default), VERBOSE, DEBUG, INFO, WARNING, ERROR.
Version 1.0.0 Highlights & Migration
zetakit_reactnative 1.0.0 is built on top of the following native SDK versions:
- Android native dependency:
net.zetaglobal.app:core:1.0.1 - iOS native dependency:
ZetaCore1.0.0
Upgrading from 0.2.x? See MIGRATION.md for the full list of breaking changes.
