Fixed notifications not being saved unless you clicked on them

- Added automatic cleanup of old notifications after 60 days
- Added deduplicateItems function to prevent the same notification to appear multiple times
- Fixed timestamp
This commit is contained in:
florian committed 2025-10-18 19:40:16 +02:00
1 parent 26e5b0ae6f
commit ed7c6d630c
7 files changed
+257 -69

No files matched your search

+100 -31
View File
@@ -1,50 +1,119 @@
# Welcome to your Expo app 👋
# Notifier app
This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).
A React Native mobile application for receiving push notifications.
## Get started
## Features
1. Install dependencies
- **Secure API Authentication** - API key-based authentication to connect to the `backend-api`
- **Notification Storage** - Notifications are saved locally and deleted after 60 days
- **Category Organization** - Notifications are organized into categories and a complete history is displayed in Home
- **Drawer Navigation** - Easy navigation between different notification categories
- **Interactive Links** - Tap on notification links to open them in your device's browser
- **Logout Functionality** - Securely unregister your device and clear all local data
```bash
npm install
```
<p align="center">
<img src="assets/images/main_menu.jpg" alt="Main Menu" width="30%"/>
<img src="assets/images/sidemenu.jpg" alt="Side Menu" width="30%"/>
<img src="assets/images/rr_category.jpg" alt="RR Category" width="30%"/>
</p>
2. Start the app
## Prerequisites
```bash
npx expo start
```
- Node.js (v14 or higher)
- Firebase account with google-services.json
- Expo account with Firebase Admin SDK private key imported
- Installed eas-cli
- Android SDK 36
- Physical Android device (push notifications don't work on simulators/emulators)
- API key
In the output, you'll find options to open the app in a
- [development build](https://docs.expo.dev/develop/development-builds/introduction/)
- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/)
- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/)
- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo
You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).
## Get a fresh project
When you're ready, run:
## Building from scratch
1. Clone the repository:
```bash
npm run reset-project
git clone <repository-url>
cd <project-directory>
```
This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.
2. Install dependencies:
```bash
npm install
```
## Learn more
3. Copy google-services.json to root directory and delete .gitignore file (or comment out google-services.json)
To learn more about developing your project with Expo, look at the following resources:
4. Use EAS to build and follow along
```bash
eas build --profile release --local --platform android
```
- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web.
## Configuration
## Join the community
### Backend URL
Join our community of developers creating universal apps.
The app connects to the notification backend at:
```
https://notifier.gansejunge.com
```
- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.
To change this, modify the `API_URL` constant in `index.tsx`.
### Categories
Categories are defined in `types/Category.ts`. Special categories:
- **Home** - View all notifications
- **Utility** - Default category for uncategorized notifications
## Technical Details
### Notification Data Structure
Notifications should include the following data fields from your backend:
```json
{
"title": "Notification Title",
"body": "Notification message text",
"data": {
"category": "utility",
"link": "https://example.com",
"timestamp": 1760734800
}
}
```
- `category` - Optional. Defaults to "utility" if not provided
- `link` - Optional. Set to "#" if no link should be shown
- `timestamp` - Optional. Defaults to when the notification was received when empty
## Project Structure
```
├── index.tsx # Main app component
├── hooks/
│ ├── usePushNotifications.ts # Push notification registration
│ └── useNotificationListener.ts # Notification receiving and storage
├── types/
│ ├── Category.ts # Category definitions
│ └── Item.ts # Notification item type
└── styles/
└── styles.ts # App styling
```
## API Endpoints
The app communicates with these backend endpoints:
- **POST /register-token** - Register device for push notifications
- Headers: `X-API-Key: <your-api-key>`
- Body: `{ token, platform, app_ver, locale, topics }`
- **POST /unregister-token** - Unregister device
- Headers: `X-API-Key: <your-api-key>`
- Body: `{ token, platform, app_ver, locale, topics }`