### Install Expo Wallet Module Source: https://github.com/giulio987/expo-wallet/blob/master/README.md Instructions for installing the @giulio987/expo-wallet module using npm or yarn. This is the initial step required before using the module's functionalities. ```bash npm install @giulio987/expo-wallet ``` ```bash yarn add @giulio987/expo-wallet ``` -------------------------------- ### React Native Wallet Integration with Expo Wallet Source: https://context7.com/giulio987/expo-wallet/llms.txt This snippet shows a complete example of integrating Expo Wallet into a React Native application. It includes checking wallet availability, fetching pass data (PKPASS for iOS, JWT for Android) from a mock API, and adding the pass to the wallet. It also handles various error codes specific to the wallet integration process and displays platform-specific messages. ```javascript import React, { useState, useEffect } from 'react'; import { View, Text, Button, Alert, Platform, ActivityIndicator, StyleSheet } from 'react-native'; import ExpoWallet from '@giulio987/expo-wallet'; const TicketScreen = ({ ticketId }) => { const [walletAvailable, setWalletAvailable] = useState(false); const [loading, setLoading] = useState(true); const [addingPass, setAddingPass] = useState(false); useEffect(() => { checkWallet(); }, []); const checkWallet = async () => { try { const available = await ExpoWallet.isAvailable(); setWalletAvailable(available); } catch (error) { console.error('Wallet check failed:', error); setWalletAvailable(false); } finally { setLoading(false); } }; const fetchPassData = async (ticketId) => { // Fetch pass data from your backend const response = await fetch(`https://api.example.com/tickets/${ticketId}/pass`, { headers: { 'Platform': Platform.OS, 'Authorization': 'Bearer YOUR_TOKEN' } }); const data = await response.json(); // Backend should return base64 .pkpass for iOS or JWT token for Android return Platform.OS === 'ios' ? data.pkpass : data.token; }; const handleAddToWallet = async () => { if (!walletAvailable) { Alert.alert('Not Available', 'Wallet is not available on this device'); return; } setAddingPass(true); try { // Fetch platform-specific pass data const passData = await fetchPassData(ticketId); // Add pass to wallet const result = await ExpoWallet.addPass(passData); if (result === true) { Alert.alert( 'Success', 'Your ticket has been added to your wallet!', [{ text: 'OK' }] ); } } catch (error) { let errorMessage = 'Failed to add ticket to wallet'; switch (error.code) { case 'E_PASS_LIBRARY_CANNOT_ADD': errorMessage = 'This ticket cannot be added. It may already be in your wallet.'; break; case 'E_PASS_LIBRARY_INVALID_DATA': errorMessage = 'Invalid ticket data. Please contact support.'; break; case 'E_PASS_LIBRARY_UNAVAILABLE': errorMessage = 'Wallet is not available on this device.'; break; case 'GOOGLE_WALLET_API_NOT_AVAILABLE': errorMessage = 'Google Wallet is not available. Please install it from Play Store.'; break; } Alert.alert('Error', errorMessage); console.error('Add to wallet error:', error); } finally { setAddingPass(false); } }; if (loading) { return ( Checking wallet availability... ); } return ( Your Ticket ID: {ticketId} {walletAvailable ? (