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-android-sinch

v1.1.7

Published

react native android module for sinch flash call

Downloads

17

Readme

react-native-android-sinch

React Native Android module for Sinch Flash Call

Installation

npm install react-native-android-sinch
yarn add react-native-android-sinch

Sinch version

com.sinch.android.sdk.verification:verification-flashcall:2.1.14

Note

The android.permission.INTERNET permission is required for the Verification SDK to work. 
To handle flash call verification automatically android.permission.READ_CALL_LOG is needed.
In case of seamless method SDK needs android.permission.
CHANGE_NETWORK_STATE to be able to automatically switch to mobile data for API calls connected with the verification process. 
Additionally, SDK collects phone metadata information connected with sim cards or phone software version, 
which are then used to handle early verification rejection rules. 
For this module to be fully functional android.permission.ACCESS_NETWORK_STATE and android.permission.READ_PHONE_STATE should be granted. 
These permissions however are not essential.

Usage

Importing the Module

import SinchFlashCall, { PermissionStatus, VerificationMethodType } from 'react-native-android-sinch';

Requesting Permissions

You need to request necessary permissions for the module to function properly. Here are the methods to request individual permissions and essential permissions.

// Request individual permissions
const requestInternetPermission = async () => {
  const status: PermissionStatus = await SinchFlashCall.requestInternetPermission();
  console.log('Internet Permission:', status);
};

const requestReadCallLogPermission = async () => {
  const status: PermissionStatus = await SinchFlashCall.requestReadCallLogPermission();
  console.log('Read Call Log Permission:', status);
};

const requestChangeNetworkStatePermission = async () => {
  const status: PermissionStatus = await SinchFlashCall.requestChangeNetworkStatePermission();
  console.log('Change Network State Permission:', status);
};

const requestAccessNetworkStatePermission = async () => {
  const status: PermissionStatus = await SinchFlashCall.requestAccessNetworkStatePermission();
  console.log('Access Network State Permission:', status);
};

const requestReadPhoneStatePermission = async () => {
  const status: PermissionStatus = await SinchFlashCall.requestReadPhoneStatePermission();
  console.log('Read Phone State Permission:', status);
};

// Request essential permissions
/**
 * @description Request essential permissions for the app to function properly.
 * This includes:
 * - Manifest.permission.READ_PHONE_STATE
 * - Manifest.permission.ACCESS_NETWORK_STATE
 * - Manifest.permission.READ_CALL_LOG
 * - Manifest.permission.INTERNET
 */
const requestEssentialPermissions = async () => {
  const status: PermissionStatus = await SinchFlashCall.requestEssentialPermissions();
  console.log('Essential Permissions:', status);
};

// Example usage
requestInternetPermission();
requestReadCallLogPermission();
requestChangeNetworkStatePermission();
requestAccessNetworkStatePermission();
requestReadPhoneStatePermission();
requestEssentialPermissions();

Initializing Verification

Ensure that the phone number is in E.164 format. The essential permissions should be requested before calling this function.

const initVerification = async () => {
  try {
    const result = await SinchFlashCall.initVerification('+12051111111', 'appKeyValue', 'appSecret');
    console.log('Verification initiated:', result);
  } catch (error) {
    console.error('Verification initiation error:', error);
  }
};

// Example usage
initVerification();

Verifying Code

If the SDK fails to intercept the call automatically, you can verify the code manually using the received call number.

const verifyCode = async (code, methodType) => {
  try {
    const result = await SinchFlashCall.verifyCode(code, methodType);
    console.log('Code verified:', result);
  } catch (error) {
    console.error('Verify code error:', error);
  }
};

// Example usage
verifyCode('12345', 'FLASHCALL');

Stopping Verification

Stop the ongoing verification process if needed.

const stopVerification = async () => {
  try {
    const result = await SinchFlashCall.stopVerification();
    console.log('Verification stopped:', result);
  } catch (error) {
    console.error('Stop verification error:', error);
  }
};

// Example usage
stopVerification();

Getting the Last Call Number from Call Log

Retrieve the last call number from the call log to use in manual verification.

const getLastCallNumberFromCallLog = async () => {
  try {
    const number = await SinchFlashCall.getLastCallNumberFromCallLog();
    console.log('Last call number:', number);
  } catch (error) {
    console.error('Get last call number error:', error);
  }
};

// Example usage
getLastCallNumberFromCallLog();

Adding Event Listeners

Subscribe to events during the verification process.

const addListener = () => {
  SinchFlashCall.addListener("verificationSuccess", (data) => {
    console.log("verificationSuccess", data);
  });
  
  SinchFlashCall.addListener("verificationFailed", (data) => {
    console.log("verificationFailed", data);
  });
};

// Example usage
addListener();

Removing Event Listeners

Remove event listeners when they are no longer needed.

const removeListener = () => {
  SinchFlashCall.removeListener("verificationSuccess");
  SinchFlashCall.removeListener("verificationFailed");
};

// Example usage
removeListener();

Removing All Event Listeners

Remove all event listeners at once.

const removeAllListeners = () => {
  SinchFlashCall.removeAllListeners();
};

// Example usage
removeAllListeners();

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library