npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@revlumofficial/react-native-offerwall

v0.1.1

Published

React Native library for integrating the Revlum Offerwall SDK. Easily configure and launch an offerwall on Android and iOS, allowing users to earn rewards through engaging offers.

Downloads

33

Readme

@revlumofficial/react-native-offerwall

React Native library for integrating the Revlum Offerwall SDK. Easily configure and launch an offerwall on Android and iOS, allowing users to earn rewards through engaging offers.

The Revlum Offerwall Plugin is a React Native plugin that wraps the native Revlum Offerwall SDK implementations for both Android and iOS. For more details on the native implementations, you can refer to the official documentation for iOS and Android.

| | Android | iOS | |-------------|-----------|-----------| | Support | minSdk 24 | iOS 16.0+ |

Installation

Install the package using yarn:

yarn add @revlumofficial/react-native-offerwall

or with npm:

npm install @revlumofficial/react-native-offerwall

Setup

Android

  1. Minimum SDK Requirement: Ensure that your Android minSdkVersion is set to 24 or higher.

  2. Add Revlum Maven Repository: In your Android project, navigate to your android/build.gradle file and ensure that the Revlum Maven repository is added under the allprojects section. It should look like this:

    allprojects {
        repositories {
            maven {
                url = uri("https://sdk-revlum-android.s3.amazonaws.com/")
                content {
                    includeGroup("com.revlum")
                }
            }
            google()
            mavenCentral()
        }
    }

iOS

  1. Modify AppDelegate.mm: In your AppDelegate.mm, set up the navigation controller as shown below:

    #import "AppDelegate.h"
    #import <React/RCTBundleURLProvider.h>
    #import <React/RCTRootView.h>
    
    @implementation AppDelegate 
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
      self.moduleName = @"OfferwallExample";
      self.initialProps = @{};
         
      // Begin: Add the following code to initialize the React Native view and set up the navigation controller. Don't forget to replace 'moduleName' with the correct value above.
      NSURL *jsCodeLocation = [self bundleURL];
    
      RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                          moduleName:@"OfferwallExample"
                                                   initialProperties:nil
                                                       launchOptions:launchOptions];
    
      UIViewController *rootViewController = [UIViewController new];
      rootViewController.view = rootView;
    
      self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
      self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
      [self.window makeKeyAndVisible];
    
      return YES;
      // End: Added code for React Native view and navigation controller setup
    }
    
    - (NSURL *)bundleURL
    {
    #if DEBUG
      return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
    #else
      return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
    #endif
    }
    
    @end

Usage

1. Configure the Offerwall

Before launching the Offerwall or checking for rewards, configure the SDK by calling the configure method. You need to provide the API key and optional parameters like userId and subId. If you do not provide a user ID, the SDK will automatically generate one. If a user ID is set, it will be used unless manually changed.

import { configure } from '@revlumofficial/react-native-offerwall';

const initOfferwall = async () => {
  try {
    await configure('your_api_key', null, 'Revlum');
  } catch (error) {
    console.error('Configure error:', error);
  }
};

2. Launch the Offerwall

After configuring the SDK, you can launch the Offerwall using the launch method:

import { launch } from '@revlumofficial/react-native-offerwall';

const handleLaunchOfferwall = async () => {
  try {
    await launch();
  } catch (error) {
    console.error('Launch error:', error);
  }
};

3. Check for rewards

Check for rewards by using the checkReward function. It returns a reward value (which will be 0 if there is no reward) and a list of conversions:

import { checkReward } from '@revlumofficial/react-native-offerwall';

const checkRewards = async () => {
  try {
    const rewardData = await checkReward();
    console.log('Reward:', rewardData.reward);
  } catch (error) {
    console.error('Check reward error:', error);
  }
};

Full Example

import { useRef, useEffect } from 'react';
import { View, Button, AppState, AppStateStatus, StyleSheet } from 'react-native';
import { configure, launch, checkReward } from '@revlumofficial/react-native-offerwall';

export default function App() {
  const appState = useRef(AppState.currentState);

  useEffect(() => {

    const _initOfferwall = async () => {
      try {
        await configure('your_api_key', null, 'Revlum');
      } catch (error) {
        console.error('Configure error:', error);
      }
    };

    _initOfferwall();

    const _checkRewards = async () => {
      try {
        const rewardData = await checkReward();
        console.log(`checkReward: reward: ${rewardData.reward}`);
      } catch (error) {
        console.error('checkReward error:', error);
      }
    };

    const subscription = AppState.addEventListener('change', (nextAppState: AppStateStatus) => {
      if (appState.current.match(/inactive|background/) && nextAppState === 'active') {
        _checkRewards();
      }
      appState.current = nextAppState;
    });

    return () => {
      subscription.remove();
    };
  }, []);

  const _handleLaunchOfferwall = async () => {
    try {
      await launch();
    } catch (error) {
      console.error('Launch error:', error);
    }
  };

  return (
    <View style={styles.container}>
      <Button title="Launch Offerwall" onPress={_handleLaunchOfferwall} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library