React Native SDK for AnnounceKit

The React Native SDK enables you to implement AnnounceKit widgets in your React Native mobile apps, so you can increase feature awareness by sharing the latest product updates right inside your app.

With the React Native SDK you can use the following AnnounceKit features:

  • Widgets with Badge Launcher
  • Segmentation
  • User Tracking

Installation

Install the SDK:

npm install announcekit-react-native

Also install react-native-webview, which is a required dependency:

npm install react-native-webview

iOS only: install the native dependencies with CocoaPods:

cd ios && pod install

Quick Start

function App() {
  return (
    <SafeAreaView style={styles.container}>
      <AnnounceKitProvider widget="https://announcekit.co/widgets/v2/4c6CdO">
        <WidgetButton />
      </AnnounceKitProvider>
    </SafeAreaView>
  );
}

function WidgetButton() {
  const unread = useUnreadCount();
  const [openWidget] = useWidget();

  if (typeof unread === "undefined") return null;

  return (
    <Button
      title={`${unread} unread posts`}
      onPress={(e) => openWidget()}
    />
  );
}

Replace the widget address with your own widget's. You find it in the dashboard: open Widgets in the sidebar, click your widget, open the Implementation tab and copy the value of the widget key in the Javascript code.

AnnounceKitProvider also accepts lang, user, data, user_token and labels, for languages, user tracking, segmentation and label filters.

Resources

Was this helpful?