UNPKG

expo-pngme-sdk

Version:

Expo SDK for Pngme financial insights - Android only, optimized for managed workflow

64 lines 2.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const config_plugins_1 = require("@expo/config-plugins"); /** * Add Pngme SDK repository and dependencies to Android project */ const withPngmeAndroid = (config, props = {}) => { const PNGME_MAVEN_URL = props.pngmeMavenUrl || 'https://jitpack.io'; const PNGME_SDK_VERSION = props.pngmeSdkVersion || '7.0.6'; // Add permissions to AndroidManifest.xml config = (0, config_plugins_1.withAndroidManifest)(config, async (config) => { const manifest = config.modResults; // Ensure permissions array exists if (!manifest.manifest.permission) { manifest.manifest.permission = []; } const requiredPermissions = [ 'android.permission.READ_SMS', 'android.permission.INTERNET', 'android.permission.ACCESS_NETWORK_STATE', ]; requiredPermissions.forEach((permission) => { const exists = manifest.manifest.permission?.some((p) => p.$?.['android:name'] === permission); if (!exists) { manifest.manifest.permission?.push({ $: { 'android:name': permission, }, }); } }); return config; }); // Add repository and dependencies to app/build.gradle config = (0, config_plugins_1.withAppBuildGradle)(config, (config) => { let buildGradle = config.modResults.contents; // Add repository if not exists if (!buildGradle.includes(PNGME_MAVEN_URL)) { const repoPattern = /repositories\s*\{/; const repoReplacement = `repositories { maven { url '${PNGME_MAVEN_URL}' }`; buildGradle = buildGradle.replace(repoPattern, repoReplacement); } // Add Pngme SDK dependency if not exists if (!buildGradle.includes('com.pngme:pngme-sdk')) { const depPattern = /dependencies\s*\{/; const depReplacement = `dependencies { implementation 'com.pngme:pngme-sdk:${PNGME_SDK_VERSION}'`; buildGradle = buildGradle.replace(depPattern, depReplacement); } config.modResults.contents = buildGradle; return config; }); return config; }; /** * Expo config plugin for Pngme SDK * Automatically configures Android permissions and dependencies */ const withPngme = (config, props) => { return withPngmeAndroid(config, props || {}); }; exports.default = withPngme; //# sourceMappingURL=withPngme.js.map