Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/isurusankhajith/fcm-push-notification-http-v1
This project demonstrates a basic implementation of Firebase Cloud Messaging (FCM) to send and receive push notifications using HTTP in an Android application. The app is built using Kotlin, Jetpack Compose, and integrates with Firebase for push notifications.
https://github.com/isurusankhajith/fcm-push-notification-http-v1
fcm-push-notification firebase http kotlin-android
Last synced: 10 days ago
JSON representation
This project demonstrates a basic implementation of Firebase Cloud Messaging (FCM) to send and receive push notifications using HTTP in an Android application. The app is built using Kotlin, Jetpack Compose, and integrates with Firebase for push notifications.
- Host: GitHub
- URL: https://github.com/isurusankhajith/fcm-push-notification-http-v1
- Owner: IsuruSankhajith
- License: mit
- Created: 2024-11-04T08:17:26.000Z (16 days ago)
- Default Branch: master
- Last Pushed: 2024-11-04T17:51:21.000Z (16 days ago)
- Last Synced: 2024-11-04T18:40:12.099Z (16 days ago)
- Topics: fcm-push-notification, firebase, http, kotlin-android
- Language: Kotlin
- Homepage:
- Size: 109 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
---
# FCM Push Notification HTTP v1
This project demonstrates a basic implementation of Firebase Cloud Messaging (FCM) to send and receive push notifications using HTTP in an Android application. The app is built using **Kotlin**, **Jetpack Compose**, and integrates with **Firebase** for push notifications.
## Features
- **Send Direct Messages**: Send notifications to a specific device using a unique FCM token.
- **Broadcast Messages**: Broadcast a notification to all subscribed devices.
- **Token Management**: Retrieve and manage FCM tokens for targeted messaging.
- **Firebase Integration**: Uses Firebase Messaging Service for handling push notifications.
- **Compose UI**: Modern Android UI using Jetpack Compose.
## Project Structure- **MainActivity**: Manages the UI and user interactions, including sending messages and requesting notification permissions.
- **ChatViewModel**: Handles business logic, sending requests to the server, and managing state.
- **PushNotificationService**: Handles the reception of push notifications and token generation.
- **Retrofit API**: Communicates with the backend to send messages or broadcasts via HTTP requests.
## How to Set Up### Prerequisites
- Android Studio installed
- Firebase account with FCM enabled
- An Android device or emulator for testing### Steps to Run
1. **Clone the Repository**:
```
git clone https://github.com/IsuruSankhajith/fcmpushnotificationhttpv1.git
```
2. **Set Up Firebase**:
- Create a new Firebase project and enable Firebase Cloud Messaging (FCM).
- Download the `google-services.json` file from Firebase and place it in the `app/` directory of the project.3. **Configure Backend URL**:
- Update the `baseUrl` in `ChatViewModel.kt` with your backend server's URL if it's different from `http://10.0.2.2:8080`.4. **Run the App**:
- Open the project in Android Studio and sync Gradle.
- Connect a device or emulator, then click the "Run" button.### API Endpoints
- `POST /send`: Sends a message to a specific device based on its FCM token.
- `POST /broadcast`: Broadcasts a message to all devices.### Permissions
Ensure the app has the following permissions in `AndroidManifest.xml`:
```xml
```
For Android 13 (Tiramisu) and above, notification permissions are requested at runtime.
## Built With
- **Kotlin** - Programming language
- **Jetpack Compose** - Modern Android UI toolkit
- **Firebase Cloud Messaging** - Push notification service
- **Retrofit** - HTTP client for sending requests## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
---