# Using Turbo Native GoProxy in Expo

This guide shows you how to integrate the `turbo-native-goproxy` Turbo Native module into your Expo project.

## Overview

You have two modules:
1. **turbo-native-goproxy** - A Turbo Native module with secure storage functionality
2. **expo-native-goproxy** - An Expo module that can wrap the Turbo Native module

## Integration Steps

### Method 1: Direct Integration (Recommended for Expo SDK 50+)

1. **Add the Turbo Native module to your Expo app's package.json:**

```json
{
  "dependencies": {
    "turbo-native-goproxy": "file:../turbo-native-goproxy"
  }
}
```

2. **Install dependencies:**

```bash
npm install
npx expo install
```

3. **Use the module in your Expo app:**

```tsx
import { setSecureItem, getSecureItem, removeSecureItem, hasSecureItem } from 'turbo-native-goproxy';

export default function App() {
  const handleSaveData = async () => {
    try {
      await setSecureItem('user_token', 'abc123');
      console.log('Data saved securely!');
    } catch (error) {
      console.error('Failed to save:', error);
    }
  };

  const handleLoadData = async () => {
    try {
      const token = await getSecureItem('user_token');
      console.log('Retrieved token:', token);
    } catch (error) {
      console.error('Failed to load:', error);
    }
  };

  return (
    <View>
      <Button title="Save Data" onPress={handleSaveData} />
      <Button title="Load Data" onPress={handleLoadData} />
    </View>
  );
}
```

### Method 2: Through Expo Module Wrapper

If you want to use the Expo module as a wrapper:

1. **Modify your expo-native-goproxy to include secure storage methods**
2. **Copy the native implementations** from turbo-native-goproxy to expo-native-goproxy
3. **Use the Expo module APIs instead**

## Available Methods

The `turbo-native-goproxy` module provides these methods:

- `setSecureItem(key: string, value: string): Promise<void>`
- `getSecureItem(key: string): Promise<string | null>`
- `removeSecureItem(key: string): Promise<void>`
- `hasSecureItem(key: string): Promise<boolean>`

## Platform Support

- **iOS**: Uses Keychain Services for secure storage
- **Android**: Uses Android Keystore with EncryptedSharedPreferences

## Building for Production

1. **For iOS**: The module automatically uses the iOS Keychain
2. **For Android**: Requires API level 23+ for full security features

## Troubleshooting

If you encounter build issues:

1. **Clean and rebuild:**
   ```bash
   npx expo run:android --clear
   npx expo run:ios --clear
   ```

2. **For iOS simulator issues**, delete derived data:
   ```bash
   rm -rf ~/Library/Developer/Xcode/DerivedData
   ```

3. **For Android build issues**, clean gradle:
   ```bash
   cd android && ./gradlew clean
   ```
