capacitor-config-reader
v0.0.6
Published
Read info.plist and strings.xml
Downloads
23
Readme
capacitor-config-reader
Simple plugin to read values from info.plist on iOS and strings.xml on Android.
Install
npm install capacitor-config-reader
npx cap syncUsage
Reading from Android strings.xml
import { ConfigReader } from 'capacitor-config-reader';
// Read a string resource from strings.xml
const result = await ConfigReader.readStringResource({ key: 'app_name' });
console.log(result.value); // Outputs the value from strings.xmlReading from iOS Info.plist
import { ConfigReader } from 'capacitor-config-reader';
// Read a value from Info.plist
const result = await ConfigReader.readInfoPlistValue({ key: 'CFBundleDisplayName' });
console.log(result.value); // Outputs the value from Info.plistExample strings.xml (Android)
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">My App</string>
<string name="api_base_url">https://api.example.com</string>
<string name="app_version">1.0.0</string>
<string name="feature_flag_debug">true</string>
</resources>Example Info.plist (iOS)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>My App</string>
<key>APIBaseURL</key>
<string>https://api.example.com</string>
<key>AppVersion</key>
<string>1.0.0</string>
<key>FeatureFlagDebug</key>
<string>true</string>
</dict>
</plist>Available Keys
Android strings.xml
The plugin can read any string resource defined in your android/app/src/main/res/values/strings.xml file. Common keys include:
app_name- The application nametitle_activity_main- Main activity titlepackage_name- Package identifiercustom_url_scheme- Custom URL scheme
iOS Info.plist
The plugin can read any key defined in your ios/App/App/Info.plist file. Common keys include:
CFBundleDisplayName- The application display nameCFBundleIdentifier- The bundle identifierCFBundleShortVersionString- The app versionCFBundleVersion- The build number
API
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>| Param | Type |
| ------------- | ------------------------------- |
| options | { value: string; } |
Returns: Promise<{ value: string; }>
readStringResource(...)
readStringResource(options: { key: string; }) => Promise<{ value: string; }>| Param | Type |
| ------------- | ----------------------------- |
| options | { key: string; } |
Returns: Promise<{ value: string; }>
readInfoPlistValue(...)
readInfoPlistValue(options: { key: string; }) => Promise<{ value: string; }>| Param | Type |
| ------------- | ----------------------------- |
| options | { key: string; } |
Returns: Promise<{ value: string; }>
