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

react-native-pure

v1.0.19

Published

React Native module for Pure SDK

Downloads

14

Readme

Pure SDK - React Native Module

Getting started

yarn add react-native-pure

After installing the module, do the following:

Android

  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import com.fluxloop.react.pure.RNPurePackage; to the imports at the top of the file
  • Add new RNPurePackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:

    include ':react-native-pure'
    project(':react-native-pure').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pure/android')
  2. Insert the following lines inside the allprojects > repositories block in android/build.gradle:

    mavenLocal()
    mavenCentral()
    jcenter()
    maven {
            url "$rootDir/../node_modules/react-native/android"
        }
    maven {url 'https://maven.google.com'}
    maven { url = "https://dl.bintray.com/fluxloop/pure/"

    For more detailed overview on Android dependencies, click here.

  3. Insert the following lines inside the dependencies block in `android/app/build.gradle``:

    compile project(':react-native-pure')
    compile fileTree(dir: "libs", include: ["*.jar"])

IMPORTANT! You also need the following dependencies if not already used by your app in your app build.gradle:

  implementation ("com.google.android.gms:play-services-ads-identifier")
  implementation ("com.google.android.gms:play-services-location")

IMPORTANT SDK 29 CHANGES: To request background location on Android 10 when targeting SDK 29, you need to add Manifest.permission.ACCESS_BACKGROUND_LOCATION as part of your location permission request. android.permission.ACCESS_BACKGROUND_LOCATION comes bundled with the SDK manifest, but if you're using the SDK without manifest merging, please add this permission manually.

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name].

  2. Go to node_modulesreact-native-pureios and add RNPure.xcodeproj.

  3. In XCode, in the project navigator, select your project.

  4. Add libRNPure.a to your project's Build PhasesLink Binary With Libraries.

  5. Under Build SettingsSearch Paths, add $(SRCROOT)/../node_modules/react-native-pure/ios as non-recursive to Header Search Paths and Framework Search Paths.

  6. In the ios folder, create a file named Podfile with the following content, or merge into your existing Podfile:

    target 'yourAppName' do
      platform :ios, '9.0' #minimum target for pure
      use_frameworks!
      pod 'PureSDK', :podspec => 'https://puresdk.azurewebsites.net/cocoapods/versions/1.0.95?key=<PWD>'
      pod 'RNPure', :path => '../node_modules/react-native-pure/ios'
      pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
    
      # Include this for RN <= 0.46
      pod 'React', path => '../node_modules/react-native'
    
      # Include this for RN >= 0.47
      pod 'React', :path => '../node_modules/react-native', :subspecs => [
        'Core',
        'CxxBridge'
      ]
      pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
      pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
      pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
    end
    • PWD will be provided by fluxLoop.

    Include pod 'PureSDKBluetooth', :podspec => 'https://puresdk.azurewebsites.net/cocoapods/bluetooth/versions/1.0.95?key=<PASSWORD> to collect Eddystone UID and Eddystone URL.

  7. Run pod install in the ios folder from a terminal window. From now on, use the xcworkspace generated by cocoapods to work on the native iOS files.

  8. Open the xcworkspace file that was generated by CocoaPods, located in the ios folder.

  9. In AppDelegate.m, add the following with the other imports: #import <PureSDK/Pure.h> Note: If 'React/RCTBundleURLProvider.h' or 'PureSDK/Pure.h can not be found, add it to your product schemes by doing the following: Navigate to ProductSchemesManage Schemes. Select + and add RNPure and React as shared target.

  10. In AppDelegate.m find the method with the launchOptions, and add the following:

[Pure initializeWithLaunchOptions:launchOptions];
  1. Click here for additional settings required (Permissions).
  2. startTracking must be called to finish initializing the iOS SDK. This can either be done in AppDelegate.m with [Pure startTracking] after the init call, or be done with the aformentioned javascript function.

Usage


import { Pure, PureResult } from 'react-native-pure';
Pure.startTrackingWithResponse((res) => {
  if (res === PureResult.PURE_ENABLED) {
    // do something
  }
});

Available methods

init()

Android only - Promise returns undefined for iOS

The SDK is initialized automatically by default. If you need to override this behaviour, you can do this by adding the following metadata to your AndroidManifest:

 <meta-data android:name="com.pure.sdk.AutoInit" android:value="false" />

To then do your manual init of the SDK:

Pure.init().then((res) => {
  // do stuff based on response
});

startTracking()

Starts tracking of the users movement. The SDK stores the previous state, so you don't have to call Pure.startTracking() every time the app launches.

Pure.startTracking();

startTrackingWithResponse()

Starts tracking of the users movement. The SDK stores the previous state, so you don't have to call Pure.startTrackingWithResponse() every time the app launches.

Pure.startTrackingWithResponse().then((res) => {
  if (res === PureResult.PURE_ENABLED) {
    // do stuff based on response
  }
});

stopTracking()

Stops tracking of the users movement.

Pure.stopTracking();

stopTrackingWithResponse()

Stops tracking of the users movement.

Pure.stopTracking().then((res) => {
  if (res === PureResult.PURE_DISABLED) {
    // do stuff based on response
  }
});

isTracking()

Returns true if user is being tracked, false if not.

Pure.isTracking().then((isTracked) => {
  // do stuff based on response
});

getClientId()

Returns the client ID.

Pure.getClientId().then((id) => {
  // do stuff based on response
});;

associateMetadata(string, json)

Used to add metadata. The type has to be unique for each model you want to preserve. If sending userinfo, it could look something like this:

const userInfo = {userId: 1234567, gender: 'male', 'birthYear': 1980};

Pure.associateMetadata('UserInfo', userInfo).then((res) => {
  // do stuff based on if response was success
});

ß

associateMetadataWithForce(string, json, boolean)

Used to add metadata by force. Boolean in argument should be true for force, false for not.

const userInfo = {userId: 1234567, gender: 'male', 'birthYear': 1980};

Pure.associateMetadataWithForce('UserInfo', userInfo, true).then((res) => {
  // do stuff based on if response was success
});

createEvent(string, json)

Used to add an event. The name describes what kind of event this is. If sending order information, it could look something like this:

const orderData = {userId: 1234567, orderId: 10001, 'timestamp': '2018-02-01T11:49:31+00:00'};

Pure.createEvent('Order', orderData).then((res) => {
  // do stuff based on if response was success
});

createEventWithForce(string, json, boolean)

Used to add an event by force. The name describes what kind of event this is. If sending order information, it could look something like this:

const orderData = {userId: 1234567, orderId: 10001, 'timestamp': '2018-02-01T11:49:31+00:00'};

Pure.createEventWithForce('Order', orderData, true).then((res) => {
  // do stuff based on if response was success
});