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-credify-plugin

v1.3.6

Published

Plugin for RN applications that utilizes Credify Collection SDK to collect data from device, supports only android platform.

Downloads

233

Readme

React Native Credify SDK Wrapper

plugin for RN applications that utilizes Credify Collection SDK to collect data from device, supports only android platform.

This plugin acts as a wrapper for Credify Native SDK.

To gain access application will need user permission on these permissions:

  • IMEI/Device ID: READ_PHONE_STATE
  • SMS: READ_SMS

SDK collection method will only collect data if the permission is granted, for example if user only accepted SMS, collection method will collect and send SMS disregarding other collection types

Minimum SDK Required 21

Target SDK Required 31+

General usage guide

1. Install the SDK

Install the wrapper by obtaining the wrapper repo and adding it to your project packages.json

npm i react-native-credify-plugin

Using android native modules in react doesn't support expo managed work flow, application must be prebuilt with full control over android platform.

If you are using expo project run the following command to rebuild the android platform application.

npx expo prebuild

2. Reviewing Permissions

Make sure that your application inclues the following permissions in android manifest file:

    <uses-permission android:name="android.permission.READ_SMS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

3. Importing library

You can start using the SDK using the following import

Sample Imports

import {
    collectData,
    initialize,
    requestPermissions,
    setUserID,
    setUserInfo,
} from 'react-native-credify-plugin'
//...

4. Initializing the SDK

To start using SDK functionalities SDK must be initialized with some identifiers that will be used to tag information collected with the user that is using the application. Usually initialization should take place right after user login.

Sample Initialization

useEffect(() => {
    initialize('your token goes here')
        .then(() => {
            // ideally after login, user identifier must be set to tag all collected data with the user
            // user id can be set
            setUserID('<logged in user ID>')
            // or use this method tag all collected data with more user-related info
            setUserInfo(
                '<User ID here>',
                '<user full name here>',
                '<mobile number here>',
            )
        })
        .catch((error) => {
            console.log('error:', error)
            // when an exception is thrown it probably means there was a critical error while initializing, check error code and error message inside the exception for more information.
        })
})

5. Requesting Permissions

User consent / approval on permissions is needed to run the collection method, to do so you can choose one of the following options:

  1. Ask user for permission from inside the client application code (can be useful if client application wants to show custom UI before asking for permissions)
  2. Or you can simply call the SDK method RequestPermissions which requests permissions for collection items that your application can collect.

Sample Permissions Request

requestPermissions()

6. Collecting and Sending Data

After gaining proper approval, you can can call CollectData to collect and send collected data securely.

// collect data
collectData()
    .then((data) => {
        // data returned contains a JSON Object that contains each type of data collected and status of collecting and sending the data
        // result 200 means success
        // other results might indicate error, please check the error codes below for more information.
        // use data
        // data contains session_id property which contains and ID related to collection process and can be used in debugging
    })
    .catch((error) => {
        console.log('error:', error)
        // when an exception is thrown it probably means there was a critical error while initializing, check error code and error message inside the exception for more information.
    })

The result of collection is a JSON string that can be decoded and can have one of the 2 formats:

  1. in case of remote data collection:
{
    "call_log": "200",
    "session_id": "<UDID Here>"
}

each collection type will have a property that contains HTTP code for the remote request response code session_id contains a unique UDID that gets sent on each request in the collection process and can be used in debugging

  1. local data collection
{
  "sms_log": { ... },
}

each collection type will have a property that contains the result of the data collected

7. Error Codes and Debugging

Initialization error codes:

| Error Code | Description | Recommendation | | -------------------------------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | 100 | Activity or Context null | Make sure the activity is not null and avoid placing initialization in splash activity | | 104 | Credify API configuration responded but configuration is null or mismatching | Update your Credify SDK | | Invalid token, response code ... | Credify API configuration responded with non-success status code | Review your token and make sure it is valid | | 103 | Unhandled Exception | Check logcat logs for more info |

Collection error codes (returned on each data type collected):

| Error Code | Description | Recommendation | | -------------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | | 200 | Data was collected and sent properly | | | 100 | Activity or Context null | Make sure the activity is not null and avoid placing initialization in splash activity | | 104 | Credify API configuration responded but configuration is null or mismatching | Update your Credify SDK | | 103 | Unhandled Exception | Check logcat logs for more info | | | Means that data was collected properly, but a network/service error occurred while sending | Get in touch with Credify Team to investigate further |

Debugging

Simply run your application in debug mode and filter logcat logs with the tag name "CredifySDK", logs messages under this tag contains log of all steps taken by the SDK and contains informational logs, logical errors, handled native exceptions and unhandled native exceptions.