Coder Social home page Coder Social logo

teknasyon-teknoloji / deepwallkids-react-native-sdk Goto Github PK

View Code? Open in Web Editor NEW
0.0 6.0 0.0 79 KB

This package gives wrapper methods for deepwall sdks.

Home Page: https://www.npmjs.com/package/deepwallkids-react-native-sdk

License: MIT License

JavaScript 38.27% Kotlin 33.58% Objective-C 26.40% Ruby 1.75%
react-native sdk deepwallkids landing

deepwallkids-react-native-sdk's Introduction

DeepWallKids (react native sdk)

  • This package gives' wrapper methods for deepwallkids sdks. iOS - Android

  • Before implementing this package, you need to have api_key and list of actions.

  • You can get api_key and actions from DeepWall Dashboard


Getting started

$ npm install deepwallkids-react-native-sdk --save

React Native 0.59 and below

Run $ react-native link deepwallkids-react-native-sdk to link the library.

Installation Notes

  • IOS

    • Set ios version to 10.0 or higher in ios/Podfile like: platform :ios, '10.0'
    • Remove flipper from ios/Podfile if exists.
    • Run $ cd ios && pod install
  • ANDROID

    • Set minSdkVersion to 21 or higher in android/build.gradle
    • Add maven { url 'https://raw.githubusercontent.com/Teknasyon-Teknoloji/deepwall-android-sdk/master/' } into android/build.gradle (Add into repositories under allprojects)
    • Make sure your min gradle version is "3.6.4" or higher in android/build.gradle. (Check troubleshooting section to see example)

Usage

Let's start

  • On application start you need to initialize sdk with api key and environment.
import DeepWallKids, { DeepWallKidsEnvironments } from 'deepwallkids-react-native-sdk';

DeepWallKids.getInstance().initialize('{API_KEY}', DeepWallKidsEnvironments.PRODUCTION);
  • Before requesting any paywall you need to set UserProperties (device uuid, country, language). See all parameters
import DeepWallKids, { DeepWallKidsUserProperties } from 'deepwallkids-react-native-sdk';

DeepWallKids.getInstance().setUserProperties(
  new DeepWallKidsUserProperties({
    uuid: 'UNIQUE_DEVICE_ID_HERE (UUID)',
    country: 'us',
    language: 'en-us',
  }),
);
  • After setting userProperties, you are ready for requesting paywall with an action key. You can find action key in DeepWall dashboard.
import DeepWallKids from 'deepwallkids-react-native-sdk';

DeepWallKids.getInstance().requestPaywall('{ACTION_KEY}');

// You can send extra parameter if needed as below
DeepWallKids.getInstance().requestPaywall('{ACTION_KEY}', {'sliderIndex': 2, 'title': 'Deepwall'});
  • You can also close paywall.
import DeepWallKids from 'deepwallkids-react-native-sdk';

DeepWallKids.getInstance().closePaywall();
  • When any of userProperties is changed, you need to call updateUserProperties method. (For example if user changed application language)
import DeepWallKids from 'deepwallkids-react-native-sdk';

DeepWallKids.getInstance().updateUserProperties({
  language: 'fr-fr',
});
  • You can validate receipts like below.
import DeepWallKids, { DeepWallKidsValidateReceiptTypes } from 'deepwallkids-react-native-sdk';

DeepWallKids.getInstance().validateReceipt(DeepWallKidsValidateReceiptTypes.RESTORE);

Events

  • There is also bunch of events triggering before and after DeepWall Actions. You may listen any event like below.
import DeepWallKids, { DeepWallKidsEventBus, DeepWallKidsEvents } from 'deepwallkids-react-native-sdk';

DeepWallKidsEventBus.getInstance().addListener(DeepWallKidsEvents.PAYWALL_OPENED, function (data) {
  console.log(
    'DeepWallKidsEvents.PAYWALL_OPENED',
    data
  );
});
  • For example, you may listen all events from sdk like below.
import { DeepWallKidsEventBus, DeepWallKidsEvents } from 'deepwallkids-react-native-sdk';

Object.values(DeepWallKidsEvents).map((item) => {
  DeepWallKidsEventBus.getInstance().addListener(item, function (data) {
    console.log(item, data);
  });
});
  • Adding and removing event listener example
import DeepWallKids, { DeepWallKidsEventBus, DeepWallKidsEvents, DeepWallKidsEnvironments } from 'deepwallkids-react-native-sdk';

componentDidMount() {
  DeepWallKidsEventBus.getInstance().addListener(DeepWallKidsEvents.PAYWALL_OPENED, this.paywallOpenedListener = data => {
    // handle the event
  })

  DeepWallKidsEventBus.getInstance().addListener(DeepWallKidsEvents.INIT_FAILURE, function (data) {
    //init failure you may call init again
    DeepWallKids.getInstance().initialize('{API_KEY}', DeepWallKidsEnvironments.PRODUCTION);
  });
}

componentWillUnmount() {
  DeepWallKidsEventBus.getInstance().removeListener(this.paywallOpenedListener);
}

iOS Only Methods

  • Sending extra data to paywall while it's open.
import DeepWallKids from 'deepwallkids-react-native-sdk';

DeepWallKids.getInstance().sendExtraDataToPaywall({appName: "My awesome app"});

Android Only Methods

  • For consumable products, you need to mark the purchase as consumed for consumable product to be purchased again.
import DeepWallKids from 'deepwallkids-react-native-sdk';

DeepWallKids.getInstance().consumeProduct('consumable_product_id');
  • Use setProductUpgradePolicy method to set the product upgrade policy for Google Play apps.
import DeepWallKids, { DeepWallKidsProrationTypes, DeepWallKidsUpgradePolicies } from 'deepwallkids-react-native-sdk';

DeepWallKids.getInstance().setProductUpgradePolicy(
  DeepWallKidsProrationTypes.IMMEDIATE_WITHOUT_PRORATION,
  DeepWallKidsUpgradePolicies.ENABLE_ALL_POLICIES
);
  • Use updateProductUpgradePolicy method to update the product upgrade policy within the app workflow before requesting paywalls.
import DeepWallKids, { DeepWallKidsProrationTypes, DeepWallKidsUpgradePolicies } from 'deepwallkids-react-native-sdk';

DeepWallKids.getInstance().updateProductUpgradePolicy(
  DeepWallKidsProrationTypes.IMMEDIATE_WITHOUT_PRORATION,
  DeepWallKidsUpgradePolicies.ENABLE_ALL_POLICIES
);

Notes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.