diff --git a/android/build.gradle b/android/build.gradle
index cb9d623..df1ce4d 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,11 +1,11 @@
buildscript {
ext {
buildToolsVersion = "34.0.0"
- minSdkVersion = 21
+ minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
- ndkVersion = "25.1.8937393"
- kotlinVersion = "1.8.0"
+ ndkVersion = "26.1.10909125"
+ kotlinVersion = "1.9.24"
}
repositories {
google()
diff --git a/ios/Podfile b/ios/Podfile
index d74e716..028d8c7 100644
--- a/ios/Podfile
+++ b/ios/Podfile
@@ -1,11 +1,13 @@
# Resolve react_native_pods.rb with node to allow for hoisting
+
+
require Pod::Executable.execute_command('node', ['-p',
'require.resolve(
"react-native/scripts/react_native_pods.rb",
{paths: [process.argv[1]]},
)', __dir__]).strip
-platform :ios, min_ios_version_supported
+platform :ios, 17.0
prepare_react_native_project!
# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
diff --git a/ios/phyllo_connect_reactnative_sample.xcodeproj/project.pbxproj b/ios/phyllo_connect_reactnative_sample.xcodeproj/project.pbxproj
index ae09616..d7f3952 100644
--- a/ios/phyllo_connect_reactnative_sample.xcodeproj/project.pbxproj
+++ b/ios/phyllo_connect_reactnative_sample.xcodeproj/project.pbxproj
@@ -466,7 +466,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
- CODE_SIGN_STYLE = Automatic;
+ CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
@@ -488,6 +488,7 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
+ SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
@@ -502,7 +503,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
- CODE_SIGN_STYLE = Automatic;
+ CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = phyllo_connect_reactnative_sample/Info.plist;
@@ -523,6 +524,7 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
+ SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
VERSIONING_SYSTEM = "apple-generic";
@@ -578,7 +580,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 13.4;
+ IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
"$(inherited)",
@@ -598,11 +600,7 @@
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
);
- OTHER_LDFLAGS = (
- "$(inherited)",
- "-Wl",
- "-ld_classic",
- );
+ OTHER_LDFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
@@ -651,7 +649,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 13.4;
+ IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
"$(inherited)",
@@ -670,11 +668,7 @@
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
);
- OTHER_LDFLAGS = (
- "$(inherited)",
- "-Wl",
- "-ld_classic",
- );
+ OTHER_LDFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
diff --git a/ios/phyllo_connect_reactnative_sample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/phyllo_connect_reactnative_sample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/ios/phyllo_connect_reactnative_sample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/ios/phyllo_connect_reactnative_sample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/phyllo_connect_reactnative_sample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/ios/phyllo_connect_reactnative_sample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/ios/phyllo_connect_reactnative_sample.xcodeproj/project.xcworkspace/xcuserdata/pankajpatel.xcuserdatad/UserInterfaceState.xcuserstate b/ios/phyllo_connect_reactnative_sample.xcodeproj/project.xcworkspace/xcuserdata/pankajpatel.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..74b66c7
Binary files /dev/null and b/ios/phyllo_connect_reactnative_sample.xcodeproj/project.xcworkspace/xcuserdata/pankajpatel.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/ios/phyllo_connect_reactnative_sample.xcworkspace/xcuserdata/mobioxy.xcuserdatad/UserInterfaceState.xcuserstate b/ios/phyllo_connect_reactnative_sample.xcworkspace/xcuserdata/mobioxy.xcuserdatad/UserInterfaceState.xcuserstate
deleted file mode 100644
index 77645cc..0000000
Binary files a/ios/phyllo_connect_reactnative_sample.xcworkspace/xcuserdata/mobioxy.xcuserdatad/UserInterfaceState.xcuserstate and /dev/null differ
diff --git a/ios/phyllo_connect_reactnative_sample.xcworkspace/xcuserdata/pankajpatel.xcuserdatad/UserInterfaceState.xcuserstate b/ios/phyllo_connect_reactnative_sample.xcworkspace/xcuserdata/pankajpatel.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..e8b3344
Binary files /dev/null and b/ios/phyllo_connect_reactnative_sample.xcworkspace/xcuserdata/pankajpatel.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/package.json b/package.json
index 5016b97..a78d02c 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,7 @@
"react": "18.2.0",
"react-native": "0.73.3",
"react-native-bouncy-checkbox": "^3.0.7",
- "react-native-phyllo-connect": "^0.3.6",
+ "react-native-phyllo-connect": "git+ssh://git@github.com:getphyllo/phyllo-connect-reactnative.git#fixes/multiple_callback",
"react-native-simple-toast": "^3.2.0"
},
"devDependencies": {
diff --git a/src/App.js b/src/App.js
index 70d4c17..8fa353a 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,87 +1,60 @@
-import React, { useEffect, useState } from "react";
-import { View, StyleSheet, TouchableOpacity, Alert, Text } from "react-native";
-import PhylloConnect from "react-native-phyllo-connect";
-import AsyncStorage from "@react-native-async-storage/async-storage";
-import BouncyCheckbox from "react-native-bouncy-checkbox";
+import React, { useEffect, useState } from 'react'
+import {
+ View,
+ StyleSheet,
+ TouchableOpacity,
+ Alert,
+ Text,
+ NativeEventEmitter,
+} from 'react-native'
+import PhylloConnect from 'react-native-phyllo-connect'
+import AsyncStorage from '@react-native-async-storage/async-storage'
+import BouncyCheckbox from 'react-native-bouncy-checkbox'
-import { createUser, createUserToken } from "./APIHandler";
-import { generateRandomString } from "./randomGenerator";
-import clientConfig from "./config";
-import Toast from "react-native-simple-toast";
+import { createUser, createUserToken } from './APIHandler'
+import { generateRandomString } from './randomGenerator'
+import clientConfig from './config'
+import Toast from 'react-native-simple-toast'
export default function ExampleApp() {
- const [existingUser, setExistingUser] = useState(false);
- const [userId, setUserId] = useState("");
- const [userToken, setUserToken] = useState("");
+ const [existingUser, setExistingUser] = useState(false)
+ const [userId, setUserId] = useState('')
+ const [userToken, setUserToken] = useState('')
useEffect(() => {
const getUserFromStorage = async () => {
- const userId = await AsyncStorage.getItem("user-id");
- const token = await AsyncStorage.getItem("user-token");
+ const userId = await AsyncStorage.getItem('user-id')
+ const token = await AsyncStorage.getItem('user-token')
if (!userId || !token) {
- return;
+ return
}
- setUserId(userId);
- setUserToken(token);
- };
-
- getUserFromStorage();
- }, []);
-
- // A callback function called upon event
- const onExitCallBack = (reason, userId) => {
- console.log(`onExit reason: ${reason}, userId: ${userId}`);
- Toast.show(`onExit reason: ${reason}, userId: ${userId}`);
- };
- const onAccountConnectedCallBack = (accountId, workplatformId, userId) => {
- console.log(
- `onAccountConnected accountId: ${accountId}, workplatformId: ${workplatformId}, userId: ${userId}`
- );
- Toast.show(
- `onAccountConnected accountId: ${accountId}, workplatformId: ${workplatformId}, userId: ${userId}`
- );
- };
- const onAccountDisconnectedCallBack = (accountId, workplatformId, userId) => {
- console.log(
- `onAccountDisconnected accountId: ${accountId}, workplatformId: ${workplatformId}, userId: ${userId}`
- );
- Toast.show(
- `onAccountDisconnected accountId: ${accountId}, workplatformId: ${workplatformId}, userId: ${userId}`
- );
- };
- const onTokenExpiredCallBack = (userId) => {
- console.log(`onTokenExpired userId: ${userId}`);
- Toast.show(`onTokenExpired userId: ${userId}`);
- };
-
- const onConnectionFailure = (reason, workplatformId, userId) => {
- console.log(
- `onConnectionFailure reason: ${reason}, workplatformId: ${workplatformId}, userId: ${userId}`
- );
- Toast.show(
- `onConnectionFailure reason: ${reason}, workplatformId: ${workplatformId}, userId: ${userId}`
- );
- };
+ setUserId(userId)
+ setUserToken(token)
+ }
+
+ getUserFromStorage()
+ }, [])
const onPressButton = async (workPlatformId) => {
- const clientDisplayName = "Phyllo Sample";
- const externalId = generateRandomString(20);
- const environment = clientConfig.env;
- const baseURL = await PhylloConnect.getEnvBaseURl(environment.toString());
- let id, token;
+ const clientDisplayName = 'Example'
+ const externalId = generateRandomString(20)
+ const environment = clientConfig.env
+ const baseURL = await PhylloConnect.getPhylloEnvironmentUrl('sandbox')
+ console.log('baseURL', baseURL)
+ let id, token
try {
// Create a user, SDK Token if the user is new user
if (existingUser) {
- id = userId;
- token = userToken;
+ id = userId
+ token = userToken
} else {
- id = await createUser(generateRandomString(8), externalId, baseURL);
- token = await createUserToken(id, baseURL);
- await AsyncStorage.setItem("user-id", id);
- await AsyncStorage.setItem("user-token", token);
- setUserId(id);
- setUserToken(token);
+ id = await createUser(generateRandomString(8), externalId, baseURL)
+ token = await createUserToken(id, baseURL)
+ await AsyncStorage.setItem('user-id', id)
+ await AsyncStorage.setItem('user-token', token)
+ setUserId(id)
+ setUserToken(token)
}
// set config
@@ -91,71 +64,126 @@ export default function ExampleApp() {
userId: id,
environment,
workPlatformId,
- };
+ }
+
+ PhylloConnect.initialize(config)
+ const eventEmitter = new NativeEventEmitter(PhylloConnect)
+
+ this.eventListener = eventEmitter.addListener(
+ 'onAccountConnected',
+ (event) => {
+ console.log(
+ `onAccountConnected accountId: ${event.accountId}, workplatformId: ${event.accountId}, userId: ${event.userId}`
+ )
+ Toast.show(
+ `onAccountConnected accountId: ${event.accountId}, workplatformId: ${event.workplatformId}, userId: ${event.userId}`
+ )
+ this.eventListener.remove()
+ }
+ )
+
+
+ this.eventListener = eventEmitter.addListener(
+ 'onAccountDisconnected',
+ (event) => {
+ console.log(
+ `onAccountDisconnectedCallBack accountId: ${event.accountId}, workplatformId: ${event.workplatformId}, userId: ${event.userId}`
+ )
+ this.eventListener.remove()
+ }
+ )
+
+
+ this.eventListener = eventEmitter.addListener(
+ 'onConnectionFailure',
+ (event) => {
+ console.log(
+ `onConnectionFailure reason: ${event.reason}, workplatformId: ${event.workplatformId}, userId: ${event.userId}`
+ )
+ Toast.show(
+ `onConnectionFailure reason: ${event.reason}, workplatformId: ${event.workplatformId}, userId: ${event.userId}`
+ )
+ this.eventListener.remove()
+ }
+ )
+
+
+ this.eventListener = eventEmitter.addListener(
+ 'onTokenExpired',
+ (event) => {
+ console.log(`onTokenExpired userId: ${event.userId}`)
+ Toast.show(`onTokenExpired userId: ${event.userId}`)
+ this.eventListener.remove()
+ }
+ )
+
- const phylloConnect = PhylloConnect.initialize(config);
- phylloConnect.on("exit", onExitCallBack);
- phylloConnect.on("tokenExpired", onTokenExpiredCallBack);
- phylloConnect.on("accountConnected", onAccountConnectedCallBack);
- phylloConnect.on("accountDisconnected", onAccountDisconnectedCallBack);
- phylloConnect.on("connectionFailure", onConnectionFailure);
+ this.eventListener = eventEmitter.addListener(
+ 'onExit',
+ (event) => {
+ console.log(`onExit reason: ${event.reason}, userId: ${event.userId}`)
+ Toast.show(`onExit reason: ${event.reason}, userId: ${event.userId}`)
+ this.eventListener.remove()
+ }
+ )
+
- phylloConnect.open();
+ PhylloConnect.open()
- console.log("Version Object", phylloConnect.version());
+ //console.log('Version Object', PhylloConnect.version())
} catch (e) {
- Toast.show(e.message);
+ Toast.show(e.message)
}
- };
+ }
return (
onPressButton("")}
+ onPress={() => onPressButton('')}
style={styles.buttonStyle}
>
Connect Platform Account(s)
onPressButton("9bb8913b-ddd9-430b-a66a-d74d846e6c66")}
+ onPress={() => onPressButton('9bb8913b-ddd9-430b-a66a-d74d846e6c66')}
style={styles.buttonStyle}
>
Connect Instagram using Phyllo
onPressButton("14d9ddf5-51c6-415e-bde6-f8ed36ad7054")}
+ onPress={() => onPressButton('14d9ddf5-51c6-415e-bde6-f8ed36ad7054')}
style={styles.buttonStyle}
- underlayColor="#fff"
+ underlayColor='#fff'
>
Connect YouTube using Phyllo
{
- setExistingUser(isChecked);
+ setExistingUser(isChecked)
}}
- text="Existing user"
+ text='Existing user'
isChecked={existingUser}
textStyle={{
- textDecorationLine: "none",
+ textDecorationLine: 'none',
}}
style={styles.checkboxStyle}
disabled={!userId || !userToken}
/>
- );
+ )
}
const styles = StyleSheet.create({
buttonStyle: {
marginVertical: 5,
- backgroundColor: "#524FA1",
- borderColor: "#524FA1",
+ backgroundColor: '#524FA1',
+ borderColor: '#524FA1',
height: 40,
- display: "flex",
- justifyContent: "center",
+ display: 'flex',
+ justifyContent: 'center',
borderRadius: 5,
- shadowColor: "black",
+ shadowColor: 'black',
shadowOpacity: 0.26,
shadowOffset: { width: 0, height: 2 },
shadowRadius: 5,
@@ -163,17 +191,17 @@ const styles = StyleSheet.create({
},
buttonText: {
- color: "#fff",
- textAlign: "center",
- fontWeight: "bold",
+ color: '#fff',
+ textAlign: 'center',
+ fontWeight: 'bold',
},
containerStyle: {
- display: "flex",
+ display: 'flex',
flex: 0.8,
marginHorizontal: 35,
- justifyContent: "center",
+ justifyContent: 'center',
},
checkboxStyle: {
marginTop: 20,
},
-});
+})
diff --git a/src/config.js b/src/config.js
index d566a6d..9ba3b24 100644
--- a/src/config.js
+++ b/src/config.js
@@ -1,11 +1,9 @@
-import { PhylloEnvironment } from "react-native-phyllo-connect";
-
-const clientId = ""; // add your Id here
-const clientSecret = ""; // add your client Secret
-const env = PhylloEnvironment.sandbox; // add your environment type, sandbox, production are the valid values
+const clientId = '' // add your Id here
+const clientSecret = '' // add your client Secret
+const env = "sandbox" // add your environment type, sandbox, production are the valid values
export default {
clientId,
clientSecret,
env,
-};
+}