Flutter DeviceConnect

The plugin can be used to integrate mobile apps with DeviceConnect so that users can share their data.

NOTE

Following will be shared by FinBox team at the time of integration:

  • ACCESS_KEY
  • SECRET_KEY
  • DC_SDK_VERSION
  • COMMON_SDK_VERSION
  • COMMON_FLAVOR
  • LOGGER_SDK_VERSION
  • CLIENT_API_KEY

Handle Permissions

The Runtime permissions needs to handled by the developer when calling the helper methods. Based on the permissions available, the SDK intelligently syncs the alternate data.

Below are the list of Runtime permissions the sdk adds to the application Manifest, if Manifest Merger is enabled:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />

Integration Flow

  1. Specify the following in local.properties file:

     ACCESS_KEY=<ACCESS_KEY>
     SECRET_KEY=<SECRET_KEY>
     DC_SDK_VERSION=<RM_SDK_VERSION>
     COMMON_SDK_VERSION=<COMMON_SDK_VERSION>
     COMMON_FLAVOR=<COMMON_FLAVOR>
     LOGGER_SDK_VERSION=<LOGGER_SDK_VERSION>
    
  2. Add plugin dependency in pubspec.yaml file:

     finbox_dc_plugin: any
    
  3. Call FinBoxDcPlugin.createUser(<CLIENT_API_KEY>, <CUSTOMER_ID>) to share users data.

     static String _deviceConnectValue = "";
     static String customerId = <CUSTOMER_ID>;
     static String apiKey = <CLIENT_API_KEY>;
    
       Future _loadDC() async {
         try {
           _deviceConnectValue = await FinBoxDcPlugin.createUser(apiKey, customerId);
         } on PlatformException catch (e) {
           _deviceConnectValue = 'Failed to fetch data';
           print(e.message);
         }
       }
    

    As success result, you will get an accessToken

Error Codes

Below table contains the constant name, error code value and the description of error code:

::: tip TIP All the constants stated below are available as constants in SDK. :::

Constant NameConstant ValueDescription
QUOTA_LIMIT_EXCEEDED7670API Key exceeded its quota limit
AUTHENTICATE_FAILED7671Authentication of the API Key and the User failed
AUTHENTICATE_API_FAILED7672Authentication of the API Key failed
AUTHORIZATION_API_FAILED7673Authorization of the API Key failed
AUTHENTICATE_API_EMPTY7676API key is empty
AUTHENTICATE_USER_EMPTY7677User name is empty
NO_ACTIVE_NETWORK7678Device is not connected to an active network
NETWORK_TIME_OUT7679Request timed out
NETWORK_RESPONSE_NULL7681Network response is null
USER_TOKENS_NULL7682Both access token and refresh token is null
ACCESS_TOKEN_NULL7683Access token is null
REFRESH_TOKEN_NULL7684Refresh token is null
AUTHENTICATE_NOT_FOUND7685End point is not found

Some error codes can be resolved by validating the implementation and some by retrying the creation of the user, while other error codes can only be resolved by contacting FinBox.

Libraries

finbox_dc_plugin