How yogendrashelke/native-cookies works
Project Type and Purpose
• This is a React Native “Native Module” library called native-cookies.
• Purpose: Expose a cross-platform JavaScript API for cookie management (get, set, clear) by bridging into Android and iOS native cookie storage.
File-Structure Analysis
• Top-level:
• src/index.js – JavaScript entry point exporting the Cookies API.
• android/ – Android native module (Kotlin classes, Gradle build).
• ios/ – iOS native module (Objective-C/Swift bindings, .podspec).
• example/ – A full React Native app demonstrating usage (both Android and iOS).
• .circleci/config.yml – CI pipeline.
• babel.config.js, tsconfig.json, package.json – tooling and packaging.
Key Insights from README
• JS API calls Cookies.get, Cookies.set, Cookies.clear, Cookies.clearAll.
• For iOS: requires CocoaPods integration.
• The library is published to npm under “native-cookies”.
Main Components
a. Consumer App (example/ or any RN app)
• JS layer imports native-cookies
• Metro bundler / React Native runtime
b. JavaScript Module
• src/index.js exposes Promise‐based API
• Babel/Javascript toolchain
c. React Native Bridge
• JS ↔ Native boundary
• automatically generated via NativeModule registry
d. Android Native Module
• NativeCookiesModule.kt / NativeCookiesPackage.kt
• Uses Android’s android.webkit.CookieManager
• Gradle build & package config
e. iOS Native Module
• NativeCookies.h / NativeCookies.m
• CocoaPods (*.podspec)
• Uses NSHTTPCookieStorage
f. Platform Cookie Storage
• Android WebView cookie store
• iOS NSHTTPCookieStorage
g. CI Pipeline (CircleCI)
• Lint, test, build steps
Interactions and Data Flow
• Branch: Bridge → Android Native Module → Android CookieManager
Bridge → iOS Native Module → NSHTTPCookieStorage
• Responses flow back along the same path (native → bridge → JS → app)
• CI pipeline triggers builds/tests on push
Architectural Patterns & Design Principles
• Bridge Pattern: JS API decoupled from platform implementations
• Module Separation: Single-responsibility modules for Android and iOS
• Platform-agnostic API: Common JS interface for both platforms
• Example App as a “consumer” micro-service to validate integration
Relevant Technologies
• JavaScript / React Native
• Kotlin (Android), Objective-C / Swift (iOS)
• Gradle (Android), CocoaPods (iOS)
• Metro bundler, Babel
• CircleCI for CI/CD