Getting Started - Maksim3l/MassHealth-Excercise GitHub Wiki
This is the MassHealth-Exercise development environment setup. This guide walks you through cloning the repository, configuring services like Supabase and MQTT, and preparing the mobile app for development.
Installation
-
Clone the repository
git clone https://github.com/Maksim3l/MassHealth-Excercise cd MassHealth-Excercise
-
Handle the "Pre-Launch Configuration" setup
-
Start the development environment using start.ps1
.\start.ps1
-
Follow the instructions on screen to run the app.
Pre-Launch Configuration
If you're using Expo Go and not building the native app, some health data must be set manually. In home.tsx (for sleep and calories) and activity.tsx (for steps, distance):
Comment out the iOS/Android hooks and set values manually:
import useHealthDataios from '../../../hooks/useHealthDataios'
// import useHealthData from '../../../hooks/useHealthData'
const androidHealthData = useHealthData(date);
// const iosHealthData = useHealthDataios(date)
let sleep = 0
let calories = 0
if (Platform.OS === 'ios') {
// sleep = iosHealthData.sleepingHours;
// calories = iosHealthData.calories;
} else if (Platform.OS === 'android') {
// steps = androidHealthData.steps;
// flights = androidHealthData.flights;
// distance = androidHealthData.distance;
sleep = androidHealthData.sleep
calories = androidHealthData.energy
}
Adjust this logic based on your platform and hook readiness. (Expo go -> comment everyhting out; Android/IOS -> comment out ios or android)
- Installation for iOS Health App: https://github.com/agencyenterprise/react-native-health
- Installation for android Health Connect App: https://github.com/matinzd/react-native-health-connect
- Tutorial for both: https://www.notjust.dev/projects/step-counter/apple-healthkit
MQTT Setup
- Start MQTT docker with start.ps1 or docker-compose up (you have to manually change ips in react native code)
- Install MQTT Explorer for visualizing MQTT topics.
- Connect with:
- Host: localhost or your IP (same as used in GlobalDataProvider.tsx)
- Port: 1883
- Leave user authentication disabled (unless configured)
- When we start the app we should see users ids each with their location, username, timestamp and presence state
In App Location Services & Map
- Ensure location permissions are enabled on your mobile device.
- After launching the app:
- You should see your location on the map.
- Your location should publish to MQTT.
Profiles & Testing
- Launch the app using Expo.
- Register two accounts.
- Use profile.tsx to:
- Add the accounts as friends.
- Send and accept friend requests.
Important Warnings
- Always sign out when you're done working, using the button in profile.tsx.
- JWT login tokens expire after ~1 hour. If expired:
- Go to profile.tsx
- Sign out, then log in again
- The token cannot be refreshed; reauthentication is required.
- ATTENTION! This is a temporary Supabase self hosted bug that can be solved