cordova-credify-plugin-sms
TypeScript icon, indicating that this package has built-in type declarations

1.3.4 • Public • Published

Cordova Credify SDK Wrapper

plugin for Cordova 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 cordova-credify-plugin

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. Using the library

You can start using the SDK once it is installed by using the window object window.Credify

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

window.Credify.initialize(
    'your token goes here',
    (response) => {
        // ideally after login, user identifier must be set to tag all collected data with the user
        // user id, name and ohone number can be set
        window.Credify.setUserInfo(
            '<user ID>',
            '<Full Name>',
            '<Phone Number>',
            (result) => {},
            (error) => {},
        )
    },
    (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

window.Credify.requestPermissions(
    (result) => {
        console.log('permission request result', result)
    },
    (error) => {
        alert('error while requesting permissions:' + error)
    },
)

6. Collecting and Sending Data

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

// collect data
window.Credify.collectData(
    (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
    },
    (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.

Package Sidebar

Install

npm i cordova-credify-plugin-sms

Weekly Downloads

2

Version

1.3.4

License

MIT

Unpacked Size

18.4 kB

Total Files

10

Last publish

Collaborators

  • credifyit