bound-sdk-react-native v1.0.1
bound-sdk-react-native
React Native package for Bound
Installation
npm install bound-sdk-react-native
For Android, add the following to your application's build.gradle
:
maven {
url "https://gitlab.com/api/v4/projects/25968876/packages/maven"
}
For iOS, in your project's ios folder, run:
pod install
Usage
Import the library:
import BoundSdkReactNative from "bound-sdk-react-native";
Get the session token you need to use with the other SDK methods:
const getSessionTokenResult = await BoundSdkReactNative.getSessionToken(
accessToken
);
if (getSessionTokenResult.success) {
const sessionToken = getSessionTokenResult.token;
}
Perform phone number verification:
const phoneCheckResult = await BoundSdkReactNative.phoneCheck(
phoneNumber,
sessionToken
);
if (phoneCheckResult.success && phoneCheckResult.match) {
// The phone number verification was successful and the phone number matches
// the value entered by the user
}
Send SMS message to a phone number:
const sendSMSResult = await BoundSdkReactNative.sendSMS(
phoneNumber,
message,
sessionToken
);
if (sendSMSResult.success) {
// SMS was successfully sent
}
API
Methods
getSessionToken()
Provides the session token needed to authorize access to other SDK methods
Signature
getSessionToken(accessToken: string): Promise<Object>
Inputs
accessToken
The unique string provided when you registered with the Bound service
Output
This method returns a promise that resolves to an object. The resolved object will depend on whether the method call was successful.
If successful:
{
success: true,
token: '...'
}
If unsuccessful:
{
success: false,
error: ... // a JS Error object containing the reason for the failure
}
phoneCheck()
Performs the phone number verification. It will determine if the supplied phone number belongs to the device being used.
Signature
phoneCheck(phoneNumber: string, sessionToken: string): Promise<Object>
Inputs
phoneNumber
The phone number to verify. This value must follow the international number according to the E.164 ITU-T recommendation (with/without the “+” sign at the beginning).
Examples:
- 447700900007
- 447100000847
- +447700600287
sessionToken
The token provided by calling the getSessionToken
method
Output
This method returns a promise that resolves to an object. The resolved object will depend on whether the method call was successful.
If successful and the supplied phone number matches the device's number:
{
success: true,
match: true,
status: 'COMPLETED'
}
If successful but the phone number wasn't match:
{
success: true,
match: undefined || false,
status: 'COMPLETED' || 'ACCEPTED' || 'ERROR'
}
If unsuccessful:
{
success: false,
error: ... // a JS Error object containing the reason for the failure
}
sendSMS()
Sends an SMS message to the supplied phone number
Signature
sendSMS(phoneNumber: string, message: string, sessionToken: string): Promise<Object>
Inputs
phoneNumber
The phone number to send a message to. This value must follow the international number according to the E.164 ITU-T recommendation (with/without the “+” sign at the beginning).
Examples:
- 447700900007
- 447100000847
- +447700600287
message
The message to send
sessionToken
The token provided by calling the getSessionToken
method
Output
This method returns a promise that resolves to an object. The resolved object will depend on whether the method call was successful.
If successful:
{
success: true
}
If unsuccessful:
{
success: false,
error: ... // a JS Error object containing the reason for the failure
}
Meta
Distributed under the MIT license. See LICENSE
for more information.