Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import StackNavigator from './src/navigation/StackNavigator';
import { store } from './src/redux/store';
import { supabase } from './src/integrations/supabase/client';

import messaging from '@react-native-firebase/messaging';
import { getMessaging, getToken, onMessage } from '@react-native-firebase/messaging';
import notifee, { EventType } from '@notifee/react-native';

import RingtoneService from './src/notifications/RingtoneService';
Expand All @@ -19,7 +19,7 @@ import {
} from './src/notifications/notificationService';

import IncomingWorkOverlay from './src/components/IncomingWorkOverlay';
import { clearIncomingWork } from './src/redux/workSlice';
import { clearIncomingWork, showIncomingWork } from './src/redux/workSlice';

function AppContainer() {
const dispatch = useDispatch();
Expand All @@ -37,16 +37,22 @@ function AppContainer() {
}

// FCM Token (future backend)
const token = await messaging().getToken();
console.log('FCM TOKEN:', token);
try {
const token = await getToken(getMessaging());
console.log('FCM TOKEN SUCCESS:', token);
} catch (error) {
console.warn('FCM TOKEN ERROR (SERVICE_NOT_AVAILABLE probable):', error.message);
// We log it as a warning so it doesn't break the app flow
}

await setupNotificationChannel();

// Foreground FCM listener (future use)
messaging().onMessage(async remoteMessage => {
onMessage(getMessaging(), async remoteMessage => {
if (remoteMessage.data?.type === 'NEW_WORK') {
await showIncomingWorkNotification(remoteMessage.data);
RingtoneService.startRingtone();
dispatch(showIncomingWork(remoteMessage.data));
}
});

Expand All @@ -59,6 +65,11 @@ function AppContainer() {
if (notificationId) {
await notifee.cancelNotification(notificationId);
}

// If detail.notification.data exists, show the overlay
if (detail.notification?.data) {
dispatch(showIncomingWork(detail.notification.data));
}
}
});
};
Expand Down
40 changes: 24 additions & 16 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@ android {
compileSdk rootProject.ext.compileSdkVersion

namespace "com.workers"

defaultConfig {
applicationId "com.workers"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 4
versionName "1.0.3"
}

signingConfigs {
debug {
storeFile file('debug.keystore')
Expand All @@ -95,26 +96,33 @@ android {
}

release {
storeFile file(GOBUILD_UPLOAD_STORE_FILE)
storePassword GOBUILD_UPLOAD_STORE_PASSWORD
keyAlias GOBUILD_UPLOAD_KEY_ALIAS
keyPassword GOBUILD_UPLOAD_KEY_PASSWORD
}

storeFile file(GOBUILD_UPLOAD_STORE_FILE)
storePassword GOBUILD_UPLOAD_STORE_PASSWORD
keyAlias GOBUILD_UPLOAD_KEY_ALIAS
keyPassword GOBUILD_UPLOAD_KEY_PASSWORD
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug

buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
release {
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"

packagingOptions {
pickFirst 'lib/arm64-v8a/libworklets.so'
pickFirst 'lib/armeabi-v7a/libworklets.so'
pickFirst 'lib/x86/libworklets.so'
pickFirst 'lib/x86_64/libworklets.so'
}
}

}

dependencies {
// The version of react-native is set by the React Native Gradle Plugin
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import 'react-native-gesture-handler';
import { AppRegistry } from 'react-native';
import messaging from '@react-native-firebase/messaging';
import { getMessaging, setBackgroundMessageHandler } from '@react-native-firebase/messaging';
import notifee, { EventType } from '@notifee/react-native';
import App from './App';
import { name as appName } from './app.json';
import { showIncomingWorkNotification } from './src/notifications/notificationService';
import RingtoneService from './src/notifications/RingtoneService';

// Background FCM handler
messaging().setBackgroundMessageHandler(async remoteMessage => {
setBackgroundMessageHandler(getMessaging(), async remoteMessage => {
if (remoteMessage.data?.type === 'NEW_WORK') {
console.log('Background FCM received', remoteMessage.data);
const notificationId = await showIncomingWorkNotification(remoteMessage.data);
Expand Down
83 changes: 80 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"@notifee/react-native": "^9.1.8",
"@react-native-async-storage/async-storage": "^2.2.0",
"@react-native-community/geolocation": "^3.4.0",
"@react-native-firebase/app": "^23.8.3",
"@react-native-firebase/messaging": "^23.8.3",
"@react-native/new-app-screen": "0.82.1",
Expand All @@ -26,6 +27,7 @@
"buffer": "^6.0.3",
"react": "19.1.1",
"react-native": "0.82.1",
"react-native-calendars": "^1.1314.0",
"react-native-dotenv": "^3.4.11",
"react-native-flash-message": "^0.4.2",
"react-native-fs": "^2.20.0",
Expand All @@ -51,7 +53,7 @@
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.3",
"@babel/runtime": "^7.25.0",
"@react-native-community/cli": "20.0.0",
"@react-native-community/cli": "^20.0.0",
"@react-native-community/cli-platform-android": "20.0.0",
"@react-native-community/cli-platform-ios": "20.0.0",
"@react-native/babel-preset": "0.82.1",
Expand Down
7 changes: 7 additions & 0 deletions src/api/Api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import axios from "axios";

const Api = axios.create({
baseURL: "http://192.168.29.153:3000",
timeout: 5000,
});
export default Api;
1 change: 0 additions & 1 deletion src/screens/AuthScreens/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ const styles = StyleSheet.create({
marginBottom: 20,
gap: 10,
top: 10,
marginBottom: 30
},

loginText: {
Expand Down
Loading