React Native KakaoAd SDK

react-native-kakao-ad

React-Native KakaoAd SDK, (Not official)

How to use

import React from "react";
import { TouchableOpacity, AppState, AppStateStatus, Platform } from "react-native";
import KakaoAd from "react-native-kakao-ad";

const App = () => {
    const appState = React.useRef<AppStateStatus>(AppState.currentState);

    React.useEffect(() => {
        KakaoAd.init("your-track-id");
        AppState.addEventListener("change", appStateHandler);

        return () => AppState.removeEventListener("change", appStateHandler);
    }, []);

    const appStateHandler = (nextAppState: AppStateStatus) => {
        if (appState.current.match(/inactive|background/) && nextAppState === "active") {
            Platform.OS === "ios" && KakaoAd.activate();
        }

        appState.current = nextAppState;
    };

    const logAllEvents = () => {
        KakaoAd.logRegistration();
        KakaoAd.logSearch({ searchString: "search-test" });
        KakaoAd.logViewContent({ contentId: "test-id" });
        KakaoAd.logViewCart();
        KakaoAd.logSignUp();
        KakaoAd.logPurchase({ currency: CurrencyCode.KRW }, [{ name: "test", price: 100, quantity: 1 }]);
    };

    return <TouchableOpacity style={{ width: 300, height: 300, backgroundColor: "green" }} onPress={logAllEvents} />;
};

Download Details:

Author: soundgym

Source Code: https://github.com/soundgym/react-native-kakao-ad

#react #react-native #mobile-apps

React Native KakaoAd SDK
2.40 GEEK