React Native SDK インストール
React NativeモジュールはiOS/Android SDKのラッパーとして動作します。
- React Native 0.70以上
- iOS: iOS SDKの要件を参照
- Android: Android SDKの要件を参照
インストール
Section titled “インストール”npm/yarnでインストール
Section titled “npm/yarnでインストール”# npmnpm install your-sdk-react-native
# yarnyarn add your-sdk-react-nativecd ios && pod installAndroid設定
Section titled “Android設定”android/app/build.gradleで設定を確認:
android { compileSdkVersion 33
defaultConfig { minSdkVersion 21 targetSdkVersion 33 }}import { YourSDK } from 'your-sdk-react-native';
// アプリ起動時に初期化YourSDK.initialize('YOUR_API_KEY');TypeScript
Section titled “TypeScript”import { YourSDK } from 'your-sdk-react-native';
const authenticate = async () => { try { const result = await YourSDK.authenticate({ username: 'user@example.com', password: 'password' }); console.log('Token:', result.token); } catch (error) { console.error('Authentication failed:', error); }};React Hooks
Section titled “React Hooks”import { useYourSDK } from 'your-sdk-react-native';
function MyComponent() { const { authenticate, isLoading, error } = useYourSDK();
const handleLogin = async () => { const result = await authenticate(username, password); // Handle result };
return ( // Your UI );}トラブルシューティング
Section titled “トラブルシューティング”リンクエラー
Section titled “リンクエラー”React Native 0.60以降は自動リンクされますが、手動リンクが必要な場合:
npx react-native link your-sdk-react-nativeメトロバンドラーのキャッシュクリア
Section titled “メトロバンドラーのキャッシュクリア”npx react-native start --reset-cache