Socket
Socket
Sign inDemoInstall

react-native-apxor-sdk

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-apxor-sdk

React Native wrapper for Apxor SDK


Version published
Weekly downloads
1.9K
increased by31.62%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-apxor-sdk

Description

React Native wrapper for Apxor SDK. Please refer Plugins section to integrate other Apxor plugins.

Getting started

For React Native version 0.59.0 and lower

Run the following command

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

$ react-native link react-native-apxor-sdk

  1. Open up android/app/src/main/java/[...]/MainActivity.java

    • Add import com.apxor.reactnativesdk.RNApxorSDKPackage; to the imports at the top of the file
    • Add new RNApxorSDKPackage() to the list returned by the getPackages() method
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
                new MainReactPackage(),
                ...
                new RNApxorSDKPackage(), <- ApxorSDK package
                ...
        );
    }
    
  2. Append the following lines to android/settings.gradle:

    include ':react-native-apxor-sdk'
    project(':react-native-apxor-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-apxor-sdk/android')
    
For React Native version 0.60.0 and higher

Run the command $ yarn add react-native-apxor-sdk

Integrate Apxor React Native Android SDK

  1. Insert the following lines inside repositories block in android/build.gradle

      maven { url "http://repo.apxor.com/artifactory/list/libs-release-android/" }
      maven { url "https://dl.bintray.com/apxor/apxor-android" }
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:

      implementation 'com.apxor.android:apxor-android-sdk-core:2.7.1@aar'
    
  3. Add the following meta-data tag inside application tag of AndroidManifest.xml file:

    <application ...>
        ...
        <meta-data android:name="APXOR_APP_ID" android:value=[REPLACE_YOUR_APXOR_APP_ID_HERE] />
        ...
    </application>
    

Plugins (Optional)

  1. Add following dependencies in build.gradle file

    // firebase-messaging version >= 11.4.0 needed for push plugin
    implementation 'com.google.firebase:firebase-messaging:20.1.0'
    
    implementation 'com.apxor.android:apxor-android-crash-reporter:1.0.5@aar'
    
    // To track uninstalls
    implementation ('com.apxor.android:apxor-android-sdk-push:1.2.2@aar') {
        exclude group: 'com.google.firebase'
    }
    
    implementation 'com.apxor.android:apxor-android-sdk-qe:1.4.0@aar'
    implementation 'com.apxor.android:surveys:1.2.8@aar'
    implementation 'com.apxor.android:wysiwyg:1.1.6@aar'
    
  2. Create plugins.json file at android/app/src/main/assets/ folder

  3. Paste the following JSON in that file

    {
      "plugins": [
        {
          "name": "crash",
          "class": "com.apxor.androidsdk.plugins.crash.CrashReporterPlugin"
        },
        {
          "name": "push",
          "class": "com.apxor.androidsdk.plugins.push.PushPlugin"
        },
        {
          "name": "surveys",
          "class": "com.apxor.androidsdk.plugins.survey.SurveyPlugin"
        },
        {
          "name": "wysiwyg",
          "class": "com.apxor.androidsdk.plugins.wysiwyg.WYSIWYGPlugin"
        }
      ]
    }
    
  4. If you have extended the FirebaseMessagingService in your application, please use below code in your extends FirebaseMessagingService class to receive Push notifications sent from Apxor dashboard

    if (remoteMessage.getFrom().equals(YOUR_FCM_SENDER_ID)) {
        // Your logic goes here
    } else {
        if (ApxorPushAPI.isApxorNotification(remoteMessage)) {
            ApxorPushAPI.handleNotification(remoteMessage, getApplicationContext());
        } else {
            // Silent or Data push notification which you can send through Apxor dashboard
        }
    }
    

Usage

import RNApxorSDK from 'react-native-apxor-sdk';
UserId:
// Syntax
RNApxorSDK.setUserIdentifier("user_id");

// Example
RNApxorSDK.setUserIdentifier("<some_user_id>");
Events:
// Syntax
RNApxorSDK.logAppEvent(event_name, properties);

// Example
RNApxorSDK.logAppEvent("ADD_TO_CART", {
    "userId": "user@example.com",
    "value": 1299,
    "item": "Sony Head Phone 1201" 
});
User Properties:
// Syntax
RNApxorSDK.setUserCustomInfo(properties);

// Example
RNApxorSDK.setUserCustomInfo({
    "city": "Hyderabad",
    "age": 12
});
Track Navigation:
If you are already using @react-navigation, Apxor SDK automatically tracks screen navigation if you follow below mentioned steps

Apxor's ApxNavigationContainer is just a wrapper over NavigationContainer which internally handles the route navigations (nested route navigations too) and take necessary actions within RNApxorSDK

To automatically track navigations, use ApxNavigationContainer and pass the same props you pass to NavigationContainer like below

import { ApxNavigationContainer } from 'react-native-apxor-sdk';
import { createStackNavigator } from '@react-navigation/stack';

const Stack = createStackNavigator();

function App() {
  
  return (
    <ApxNavigationContainer theme={yourTheme} linking={yourLinkingOptions} fallback={yourFallbackNode} {...others}>
      <Stack.Navigator initialRouteName="Home">
        <Stack.Screen name="Home" component={Home} />
        <Stack.Screen name="Details" component={DetailsScreen}/>
        <Stack.Screen name="FlatList" component={FlatListSample}/>
      </Stack.Navigator>
    </ApxNavigationContainer>
  );
}

######Otherwise:

// Syntax
RNApxorSDK.logNavigationEvent(screen_name);

// Example
RNApxorSDK.logNavigationEvent("LoginScreen");

Keywords

FAQs

Package last updated on 29 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc