Ứng dụng Pet Tracker giúp theo dõi vị trí hiện tại (GPS) của thú cưng (hoặc thiết bị gắn tracker) theo thời gian thực bằng Firebase Realtime Database và hiển thị trực quan trên bản đồ (OpenStreetMap) trong app Expo React Native.
- Hiển thị vĩ độ / kinh độ mới nhất từ Firebase Realtime Database
- Realtime update: tự động cập nhật khi
gps_datathay đổi - Xem bản đồ (OpenStreetMap) bằng
WebView - Nút Reset vị trí: fetch lại dữ liệu mới nhất từ Firebase
- Expo / React Native
- TypeScript (
App.tsx,AppStyles.ts) - Firebase Realtime Database
- OpenStreetMap embed qua
react-native-webview
Thư viện chính :
expo-locationfirebasereact-native-webviewexpo-linear-gradient
App.tsx— Màn hình chính: lắng nghegps_datarealtime + hiển thị bản đồAppStyles.ts— StyleSheetfirebaseConfig.js— Khởi tạo Firebase app + exportdbassets/— icon/splash…
- Node.js (khuyến nghị bản LTS)
- Expo CLI (dùng qua
npx)
npm installnpx expo startSau đó bạn có thể mở bằng:
- Expo Go trên điện thoại
- Android Emulator / iOS Simulator
File: firebaseConfig.js
- Tạo project trên Firebase Console
- Tạo Realtime Database
- Lấy cấu hình Firebase Web App
Trong App.tsx có sẵn code:
writeLocation(lat, lng)getCurrentLocation()(xin quyền + lấy GPS)
Nếu bạn muốn app đóng vai trò "thiết bị tracker", bạn có thể:
- Bỏ comment 2 hàm trên
- Gọi
getCurrentLocation()theo nút bấm hoặc theo timer (ví dụ mỗi 5–10 giây)
Lưu ý: Khi bật GPS, bạn cần cấu hình permission đúng cho Expo/Android/iOS theo hướng dẫn
expo-location.