expo-finance-kit
Version:
Native Expo module for Apple FinanceKit - Access financial data from Apple Card and other accounts
39 lines • 1.17 kB
JavaScript
import ExpoFinanceKit from './ExpoFinanceKitModule';
/**
* Request authorization and return the final status
* This handles the async nature of the authorization flow
*/
export async function requestAuthorizationWithStatus() {
try {
// Request authorization
const granted = await ExpoFinanceKit.requestAuthorization();
// Get the updated status after authorization
const status = await ExpoFinanceKit.getAuthorizationStatus();
return {
granted,
status
};
}
catch (error) {
console.error('Error requesting FinanceKit authorization:', error);
return {
granted: false,
status: 'denied'
};
}
}
/**
* Helper to ensure we have authorization before accessing financial data
*/
export async function ensureAuthorized() {
const status = await ExpoFinanceKit.getAuthorizationStatus();
if (status === 'authorized') {
return true;
}
if (status === 'notDetermined') {
const { granted } = await requestAuthorizationWithStatus();
return granted;
}
return false;
}
//# sourceMappingURL=helpers.js.map