项目作者: soundgym

项目描述 :
Kakao-Ad SDK for react-native
高级语言: Java
项目地址: git://github.com/soundgym/react-native-kakao-ad.git
创建时间: 2020-06-03T07:27:26Z
项目社区:https://github.com/soundgym/react-native-kakao-ad

开源协议:MIT License

下载


RNKakaoAd
NPM version
NPM downloads

react-native-kakao-ad

React-Native KakaoAd SDK, (Not official)

Setup

  • Android

Add below dependencies to your project/android/build.gradle

  1. allprojects {
  2. repositories {
  3. + google()
  4. + jcenter()
  5. + maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/' }
  6. }
  7. }

How to use

  1. import React from "react";
  2. import { TouchableOpacity, AppState, AppStateStatus, Platform } from "react-native";
  3. import KakaoAd, { CurrencyCode } from "react-native-kakao-ad";
  4. const App = () => {
  5. const appState = React.useRef<AppStateStatus>(AppState.currentState);
  6. React.useEffect(() => {
  7. KakaoAd.init("your-track-id");
  8. AppState.addEventListener("change", appStateHandler);
  9. return () => AppState.removeEventListener("change", appStateHandler);
  10. }, []);
  11. const appStateHandler = (nextAppState: AppStateStatus) => {
  12. if (appState.current.match(/inactive|background/) && nextAppState === "active") {
  13. Platform.OS === "ios" && KakaoAd.activate();
  14. }
  15. appState.current = nextAppState;
  16. };
  17. const logAllEvents = () => {
  18. KakaoAd.logRegistration();
  19. KakaoAd.logSearch({ searchString: "search-test" });
  20. KakaoAd.logViewContent({ contentId: "test-id" });
  21. KakaoAd.logViewCart();
  22. KakaoAd.logSignUp();
  23. KakaoAd.logPurchase({ currency: CurrencyCode.KRW }, [{ name: "test", price: 100, quantity: 1 }]);
  24. };
  25. return <TouchableOpacity style={{ width: 300, height: 300, backgroundColor: "green" }} onPress={logAllEvents} ></TouchableOpacity>;
  26. };