In your React Native project directory:
npm install react-native-phyllo-connect
Then install iOS dependencies using cocoapods:
cd ios && pod install
import PhylloConnect from 'react-native-phyllo-connect'
import PhylloConnect, { PhylloEnvironment } from "react-native-phyllo-connect";
const config = {
clientDisplayName: clientDisplayName, // the name of your app that you want the creators to see while granting access
environment: 'sandbox', // the mode in which you want to use the SDK, `sandbox` or `production`
userId: userId, // the unique user_id parameter returned by Phyllo API when you create a user (see https://docs.getphyllo.com/docs/api-reference/reference/openapi.v1.yml/paths/~1v1~1users/post)
token: token,
workPlatformId: workPlatformId, // (optional) the unique work_platform_id of a specific work platform, if you want the creator to skip the platform selection screen and just be able to connect just with a single work platform
};
const phylloConnect = PhylloConnect.initialize(config);
Arguments | Value | Type |
---|---|---|
clientDisplayName | Client Display Name | String |
token | User Token | String |
userId | User Id | String |
environment | Environment | String //'sandbox', 'production' are the valid values |
workPlatformId | Platform Id (optional) | String or Null |
phylloConnect.on("accountConnected", (accountId, workplatformId, userId) => { // gives the successfully connected account ID and work platform ID for the given user ID
console.log(`onAccountConnected: ${accountId}, ${workplatformId}, ${userId}`);
})
phylloConnect.on("accountDisconnected", (accountId, workplatformId, userId) => { // gives the successfully disconnected account ID and work platform ID for the given user ID
console.log(`onAccountDisconnected: ${accountId}, ${workplatformId}, ${userId}`);
})
phylloConnect.on("tokenExpired", (userId) => { // gives the user ID for which the token has expired
console.log(`onTokenExpired: ${userId}`);
})
phylloConnect.on("exit", (reason, userId) => { // indicated that the user with given user ID has closed the SDK and gives an appropriate reason for it
console.log(`onExit: ${reason}, ${userId}`);
})
phylloConnect.on("connectionFailure", (reason, workplatformId, userId) => { // optional, Connection failure callback support : User can now add a new callback connectionFailure for tracking the reason of accounts not getting connected , this is optional callback .
console.log(`onConnectionFailure: ${reason}, ${workplatformId}, ${userId}`);
})
phylloConnect.open();
console.log('Version Details', phylloConnect.version())
Try our sample app
Facing any issue? We have listed solutions for some comman issues here, If it doesn't help you, feel free to raise an issue in the issues section or report your issue on #bug-reports channel of our Discord server.
Phyllo, [email protected]
PhylloConnect is available under the MIT license. See the LICENSE file for more information.