appodeal / react-native-hssdk

Holistic Solution SDK plugin for React Native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-native-hssdk

React Native package that adds Holistic Solution SDK support to your react-native application.

Table of Contents

Installation

Run following commands in project root directory

yarn add react-native-hssdk

iOS

  1. Go to ios folder and run
pod install

If you use use_frameworks! you can be faced with the problem of CocoaPods installation such this:

[!] The 'Pods-{TARGET}' target has transitive dependencies that include statically linked binaries: (FirebaseCore, FirebaseCoreDiagnostics, GoogleDataTransportCCTSupport, GoogleDataTransport, FirebaseInstallations, FirebaseRemoteConfig, and FirebaseABTesting)

You could add pre_install hook to the bottom of the project's Podfile:

pre_install do |installer|
  installer.pod_targets.each do |pod|
    if pod.name.start_with?('RNFB')
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end
  1. Add all required data that is necessary for services work:

Android

  1. Add all required data that is necessary for services work:
  1. Resolve AndroidManifest.xml conflicts
<manifest 
  xmlns:android="http://schemas.android.com/apk/res/android"
  ...
  xmlns:tools="http://schemas.android.com/tools"
>
  ...
  <application
    ...
    android:allowBackup="false"
    android:fullBackupContent="false"
    tools:replace="android:fullBackupContent,android:allowBackup"
  >

Usage

Holistic Solution will initialise all services: Facebook Analytics, Firebase Remote Config, AppsFlyer. And sync theirs data with Appodeal. After all services is initialised Holistic Solution will resolve.

Initialisation

At the application start moment you need to call configure method. After this promise is resolved you could initialise Appodeal SDK.

Note. To maximise your ad revenue, initialise Appodeal SDK even in catch function.

import { HolisticSolution } from 'react-native-hssdk';

const hsconfig = {
    timeout: 30,
    appsFlyer: {
        devKey: "YOUR APPSFLYER DEV KEY",
        appId: "YOUR APPSFLYER APP ID (iOS)",
    }, 
    firebase: {
        defaults: {
            "feature_1": "enabled",
            "feature_2": "disabled"
        },
    }
}

export const App = () => {
    useEffect(() => {
        HolisticSolution.configure(hsconfig)
        .then(() => {
          console.log("Holistic solution has been configured");
          // Initialise Appodeal here
        })
        .catch(error => {
            console.log("Holistic solution error: " + error)
            // Initialise Appodeal here
        });
    }, []);

Events

Holistic Solution can track events in all services.

// Name only
HolisticSolution.trackEvent("game_started");
// Name and parameters
HolisticSolution.trackEvent("game_finished", {"difficulty": "medium"})

Purchases

Holistic soltution can validate and track in-app purchases by AppsFlyer service

const iOSPurchase = {
  price: "0.99",
  productId: "unique product",
  transactionId: "XXX",
  currency: "USD",
  additionalParameters: {}  
}

const AndroidPurchase = {
  price: "0.99",
  currency: "USD",
  publicKey: "unique key",
  signature: "signature",
  purchaseData: "purchase data",
  additionalParameters: {}  
}

HolisticSolution.validateAndTrackInAppPurchase(Platform.OS === 'ios' ? iOSPurchase : AndroidPurchase)
  .then(response => console.log("Purchase is valid: " + response))
  .catch(error => console.log("Purchase is invalid: " + error));

Changelog

About

Holistic Solution SDK plugin for React Native


Languages

Language:Java 45.2%Language:Objective-C 25.5%Language:TypeScript 12.3%Language:Ruby 9.6%Language:Starlark 5.0%Language:JavaScript 2.5%