How jmsavani/capacitor-android-call-logs works
Main Components
• Example App (Host)
– A web-based frontend (example/src/…) that runs inside Capacitor.
• Capacitor Core Runtime
– Bridges JS calls to native layers via the Plugin Bridge.
• Plugin JS/TS Layer
– src/index.ts: public API (echo, checkPermission, isEnabled, getCallLogs)
– src/web.ts: web fallback implementation
– src/definitions.ts: type definitions for all methods
– rollup.config.js: bundling for npm package
• Native Android Plugin
– android/src/main/java/com/cap/call/logs/CapacitorCallLogsPlugin.java
– Queries Android CallLog content provider
– Gradle build scripts under android/
• Native iOS Plugin
– ios/Plugin/CapacitorCallLogsPlugin.swift + Obj-C headers
– Xcode project under ios/Plugin.xcodeproj
• Operating System Services
– Android ContentResolver > CallLog Provider
– (iOS: not implemented; calls throw or no‐op)
Relationships & Data Flow
1. Example App invokes a method: CallLogs.getCallLogs({…})
2. Plugin JS calls Capacitor.Plugins.CallLogs via the Capacitor Bridge
3. Bridge routes call to platform plugin:
– Android: JNI invocation → Java Plugin class → ContentResolver query → return JSON array
– iOS: Swift Plugin method stub (no API) → return not-supported or error
– Web: fallback defined in web.ts → return Promise.reject or stub
4. Result propagates back through the bridge to JS, then to Example App
Architectural Patterns & Principles
– Adapter/Bridge Pattern: abstracts native calls behind a uniform JS API
– Single-Responsibility: separate TS definitions, web fallback, platform implementations
– Modular Build: rollup for JS packaging, Gradle/Xcode for native builds
– Cross-Platform Plugin Structure: consistent folder layout for android/ ios/ src/
Technologies & Frameworks
– Capacitor (runtime, plugin bridge)
– TypeScript + Rollup (package, definitions, web fallback)
– Java + Android SDK (plugin implementation, Gradle)
– Swift/Objective-C + Xcode (iOS plugin project)
– Example app: HTML/JS/CSS + Vite