UNPKG

@1flow-inc/react-native-1flow-sdk

Version:
84 lines (68 loc) 2.08 kB
// main index.js import { NativeEventEmitter, NativeModules } from "react-native"; const { RN1Flow } = NativeModules; export default class OneFlow { static eventEmitter1Flow = new NativeEventEmitter(RN1Flow); static async configure(projectKey, enableSurveys) { if (projectKey === undefined) { projectKey = ""; } else if (enableSurveys === undefined) { enableSurveys = true; } if(projectKey && typeof projectKey !== "string"){ return console.error("In project Config -> Project Key must be a valid key as string") } if(typeof enableSurveys !== "boolean"){ return console.error("In project Config -> Enable Surveys must be boolean value"); } return RN1Flow.configure(projectKey, enableSurveys); } static async enableSurveys(enableSurveys) { if (enableSurveys === undefined || enableSurveys === null) { enableSurveys = true; }else if(enableSurveys !== false){ enableSurveys = true; } return RN1Flow.enableSurveys(enableSurveys); } static async useFont(fontFamily, path) { if (fontFamily === undefined) { fontFamily = ""; } else if (path === undefined) { path = ""; } return RN1Flow.useFont(fontFamily, path); } static async recordEventName(evetName, parameters = null) { if (evetName === undefined) { evetName = ""; } if(parameters != null){ return RN1Flow.recordEventName(evetName, parameters); }else{ return RN1Flow.recordEventNameWithoutParam(evetName); } } static async logUser(uniqueId, userDetails = null) { if (uniqueId === undefined) { uniqueId = ""; } if(userDetails != null){ return RN1Flow.logUser(uniqueId, userDetails); }else{ return RN1Flow.logUserWithoutParam(uniqueId); } } static async startFlow(flowId) { if (flowId === undefined) { flowId = ""; } return RN1Flow.startFlow(flowId); } static async showInbox() { return RN1Flow.showInbox(); } // static async sdkVersion() { // return "2023.3.10"; // } }