DEV Community

Cover image for How I Built a Privacy-First Android Notification Mirroring App in React Native
Aakash Hebbar
Aakash Hebbar

Posted on

How I Built a Privacy-First Android Notification Mirroring App in React Native

When I decided to build Pairio, an app that securely mirrors notifications between two Android devices, I knew the technical requirements would be steep.

The app needed to intercept notifications in real-time on one device, instantly transmit them to a paired device, and run continuously in the background without being killed by Android's aggressive battery optimizations. Most importantly, it had to be 100% private and secure with zero data retention.

Here’s a deep dive into the architecture, the tools I chose, and the challenges I overcame building this entirely in React Native.

Why Not Use Existing Apps? (Pairio vs. Same Notification)

Before writing a single line of code, I looked at existing solutions on the market like "Same Notification." While apps like Same Notification paved the way for device mirroring, I found their technical implementation lacking when it came to modern privacy standards and battery efficiency. I wanted an architecture that guaranteed End-to-End (E2E) encryption, offered a smoother React Native UI, and didn't lock core functionality behind a paywall. Building it from scratch was the only way to achieve that level of control.

1. Intercepting Notifications (NotificationListenerService)

The core of the "Sender" device is intercepting notifications as they arrive. Android provides a robust API for this: NotificationListenerService.
Because React Native doesn't have a built-in way to hook into this natively, I had to bridge it.
When a notification hits the Android system, the background service captures the payload (Title, Text, App Package Name, and Icon). The biggest challenge here was handling the sheer volume of data efficiently.

To prevent the app from drowning in background noise, I implemented a Smart Filter system locally. Before a notification is ever processed or encrypted, Pairio checks the package name against a user-defined whitelist (e.g., com.whatsapp, com.instagram.android). If it doesn't match, the payload is immediately dropped.

2. Real-Time Communication & Security

Once a notification is intercepted and passes the filter, it needs to reach the "Receiver" device instantly.

The Pairing Process (TOTP)

I didn't want users dealing with complex account setups or sharing passwords. Instead, I opted for a secure 6-digit pairing code mechanism. This acts as a short-lived handshake to establish a trusted tunnel between the Sender and Receiver.

End-to-End Encryption

Because notifications contain highly sensitive data (bank alerts, private messages), routing them as plaintext was out of the question.
The payload is heavily encrypted before it leaves the Sender device. It bounces through the routing server for mere milliseconds and is decrypted only when it arrives on the Receiver device. Zero data retention.

3. Surviving Android's Battery Optimizations

If you've ever built a background-heavy Android app, you know that OEMs (like Samsung, Xiaomi, and OnePlus) love to kill background services to save battery.
To keep the bridge alive:

  1. Foreground Services: Pairio runs a persistent Foreground Service (complete with the required sticky notification).
  2. Wakelocks & Permissions: I had to explicitly request the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission. (Google Play is very strict about this, but for a mirroring app, it is a legitimate core requirement).
  3. Graceful Reconnection: If the OS does manage to kill the service, the React Native lifecycle methods are equipped to gracefully reconnect the socket the moment the OS wakes the app back up.

4. Why React Native?

You might wonder why I didn't just build this natively in Kotlin.
React Native allowed me to iterate on the UI incredibly fast. The shared state management, the ease of building the "Smart Filters" dashboard, and the cross-platform potential made it the perfect choice. Bridging the few native Android APIs (like NotificationListenerService) was a small price to pay for the massive boost in frontend development speed.

The Result

The result is Pairio, a completely free, ad-free, and subscription-free tool that parents and professionals can actually trust.

If you're interested in checking out how smooth a React Native background app can feel, you can grab it on the Google Play Store.

Have you ever wrestled with Android's Foreground Services in React Native? Let me know your worst battery-optimization horror stories in the comments!

Top comments (0)