=== Techvoot Push Notifier for Firebase ===
Contributors: techvootsolutions
Tags: firebase, push notifications, fcm, firestore, notifications
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 2.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Send Firebase Cloud Messaging push notifications to your app users from WordPress and sync your users from Firebase Firestore.

== Description ==

Techvoot Push Notifier for Firebase connects your WordPress site to your Firebase project. It lets you schedule push notifications from the WordPress admin and delivers them to your mobile app users through Firebase Cloud Messaging (FCM HTTP v1).

Users can be taken from your Firebase Firestore `user` collection (synced into WordPress once a day or on demand) or from your WordPress users.

= Key Features =

* **Scheduled push notifications** - Create notifications in WordPress and send them automatically at the chosen date and time.
* **Firebase user sync** - Import users from Firestore daily, or manually from the dashboard.
* **Field mapping** - Map your Firestore user fields (user ID, name, email, device token, device type, category) to the plugin.
* **Firebase dashboard** - See users, notifications, delivery logs and scheduled jobs in one place.
* **Connection test** - Check your Firebase project, service account JSON key and Firestore access from WordPress.
* **Test notification** - Send a test push to an Android or iOS device token.
* **Delivery logs** - Track success or failure, device type, sent date and the Firebase response for every notification.
* **REST API** - Your app can read a logged-in user's notification history.

== Installation ==

1. Upload the plugin through **Plugins > Add New > Upload Plugin**, or copy the `techvoot-app-firebase` folder to `/wp-content/plugins/`.
2. Activate **Techvoot Push Notifier for Firebase** from the **Plugins** screen.
3. Go to **Push Notifier > Configuration > Firebase Config**:
    * Enter your **Firebase Database Name** (your Firebase project ID).
    * Upload your Firebase **service account JSON key** (Firebase Console > Project settings > Service accounts > Generate new private key).
4. Go to **Push Notifier > Configuration > Firebase Mapping** and map your Firestore user fields.
5. Go to **Push Notifier**, choose who should receive notifications (Firebase users or WordPress users), then use **Test Firebase Connection** and **Sync Users Now**.
6. Create notifications under **Notifications > Add Notification**.

== Frequently Asked Questions ==

= Does the plugin contact Firebase when it is activated? =

No. Nothing is sent to Google or Firebase until an administrator has entered the Firebase settings.

= What does my server need? =

PHP 7.4 or newer with the OpenSSL extension, which is used to sign the service account request. If OpenSSL is missing, the plugin shows a notice in the admin.

= How can my app read a user's notification history? =

Send an authenticated GET request to `/wp-json/tvfb/firebase/v1/get-user-notification` with the `user_id` parameter. Optional parameters are `page` and `per_page_data` (maximum 100). Users can only read their own log. Administrators can read any log.

= Is my data deleted when I deactivate the plugin? =

No. Deactivating only stops the scheduled jobs. Your settings, synced users and logs are kept.

== External Services ==

This plugin connects to Google Firebase services to send push notifications and to read your Firebase users. It only connects after an administrator has configured it.

= Firebase Cloud Messaging (FCM) =

* **Purpose:** Sends push notifications to user devices.
* **Data sent:** Notification title and message, device tokens, related post details and the Firebase project ID.
* **When:** When a scheduled notification is sent, or when an administrator sends a test notification.
* **Endpoint:** fcm.googleapis.com
* **Provider:** Google LLC - [Terms of Service](https://firebase.google.com/terms/), [Privacy Policy](https://firebase.google.com/support/privacy)

= Google OAuth 2.0 =

* **Purpose:** Gets a short-lived access token for the Firebase APIs.
* **Data sent:** A request signed with your service account (client email and signed token).
* **When:** Each time notifications are sent.
* **Endpoint:** oauth2.googleapis.com
* **Provider:** Google LLC - [Terms of Service](https://developers.google.com/terms/), [Privacy Policy](https://policies.google.com/privacy)

= Cloud Firestore =

* **Purpose:** Reads your users from the Firestore `user` collection.
* **Data sent:** Your Firebase project ID and the collection being requested.
* **When:** During the daily user sync, or when an administrator clicks "Sync Users Now" or "Test Firebase Connection".
* **Endpoint:** firestore.googleapis.com
* **Provider:** Google LLC - [Terms of Service](https://cloud.google.com/terms/), [Privacy Policy](https://cloud.google.com/terms/cloud-privacy-notice)

All requests use HTTPS. No data is shared with any other third party.

== Changelog ==

= 2.0.1 - 2026-09-25 =
* Fixed: Activation warnings and database table creation (dbDelta-compliant schema for all plugin tables).
* Fixed: Plugin styles and scripts now load only on the plugin's own admin screens.
* Fixed: The notification log REST endpoint only returns logs that belong to the logged-in user (administrators can view all).
* Fixed: The daily user sync no longer contacts Firebase before the plugin is configured.
* Changed: All functions, classes, options, hooks, database tables and meta keys now use the unique `tvfb` / `techvoot_app_firebase` prefix.
* Changed: The REST API namespace is now `tvfb/firebase/v1`.
* Changed: The admin menu is renamed to "Push Notifier" and all admin text is translatable.
* Changed: Deactivating the plugin no longer deletes plugin data.
* Changed: Plugin display name is now "Techvoot Push Notifier for Firebase".
* Updated: Bundled libraries (Select2 4.1.0, DataTables 2.3.8), now loaded locally instead of from a CDN.
* Improved: All HTTP requests use the WordPress HTTP API and file uploads use `wp_handle_upload()`.
* Improved: Sanitization of all settings fields.
* Removed: An unused post type and legacy FCM code.

= 2.0.0 - 2026-06-25 =
* Added: Firebase dashboard with user, notification, delivery log and cron summary cards.
* Added: Firebase connection test for Firestore access and service account setup.
* Added: Test push notifications for Android and iOS device tokens.
* Added: Manual Firebase user sync from the dashboard with inserted, updated and skipped counts.
* Improved: Notification logs with status, device type, sent date and Firebase API response.
* Improved: Scheduled notification handling, sent status and REST API notification history.
* Changed: Firebase Cloud Messaging now uses HTTP v1 with a service account JSON key.
* Improved: Admin security, AJAX nonce checks, escaping and sanitization.

= 1.0.1 - 2025-03-18 =
* Fixed: Cron job for scheduled notifications.
* Added: Daily Firebase user sync cron job.
* Added: Firebase users are saved in the WordPress database.
* Added: Notification log and a Notification Logs admin page.
* Improved: Handling of Firebase API keys.
* Improved: Settings panel UI.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 2.0.1 =
Fixes activation warnings, loads assets only on plugin screens and secures the notification log REST endpoint. The REST namespace changed to tvfb/firebase/v1.

= 2.0.0 =
Adds the Firebase dashboard, HTTP v1 push notifications, improved logs and stronger security.

= 1.0.1 =
Fixes scheduled notification cron reliability and adds a daily Firebase user sync.
