delete firebase

This commit is contained in:
Samandar Turgunboyev
2025-09-04 19:13:14 +05:00
parent f41451c6b8
commit 34fb3e357a
12 changed files with 305 additions and 1432 deletions

239
App.tsx
View File

@@ -13,8 +13,6 @@ import {
Animated, Animated,
Dimensions, Dimensions,
LogBox, LogBox,
PermissionsAndroid,
Platform,
StatusBar, StatusBar,
StyleSheet, StyleSheet,
View, View,
@@ -22,16 +20,6 @@ import {
import Toast from 'react-native-toast-message'; import Toast from 'react-native-toast-message';
// Screens // Screens
import notifee, { AndroidImportance } from '@notifee/react-native';
import { getApp } from '@react-native-firebase/app';
import {
getInitialNotification,
getMessaging,
getToken,
onMessage,
onNotificationOpenedApp,
} from '@react-native-firebase/messaging';
import DeviceInfo from 'react-native-device-info';
import Login from 'screens/auth/login/ui'; import Login from 'screens/auth/login/ui';
import Confirm from 'screens/auth/login/ui/Confirm'; import Confirm from 'screens/auth/login/ui/Confirm';
import Register from 'screens/auth/registeration/ui'; import Register from 'screens/auth/registeration/ui';
@@ -46,7 +34,6 @@ import RestrictedProduct from 'screens/home/restrictedProduct/ui/RestrictedProdu
import CreatePassword from 'screens/passport/createPassport/ui/CreatePassword'; import CreatePassword from 'screens/passport/createPassport/ui/CreatePassword';
import Passport from 'screens/passport/myPassport/ui/Passport'; import Passport from 'screens/passport/myPassport/ui/Passport';
import Profile from 'screens/profile/myProfile/ui/Profile'; import Profile from 'screens/profile/myProfile/ui/Profile';
import Notifications from 'screens/profile/notifications/ui/Notifications';
import AddedLock from 'screens/profile/settings/ui/AddedLock'; import AddedLock from 'screens/profile/settings/ui/AddedLock';
import Settings from 'screens/profile/settings/ui/Settings'; import Settings from 'screens/profile/settings/ui/Settings';
import SettingsLock from 'screens/profile/settings/ui/SettingsLock'; import SettingsLock from 'screens/profile/settings/ui/SettingsLock';
@@ -68,107 +55,107 @@ const Stack = createNativeStackNavigator();
const screenWidth = Dimensions.get('window').width; const screenWidth = Dimensions.get('window').width;
const queryClient = new QueryClient(); const queryClient = new QueryClient();
const saveNotification = async (remoteMessage: any) => { // const saveNotification = async (remoteMessage: any) => {
try { // try {
const stored = await AsyncStorage.getItem('notifications'); // const stored = await AsyncStorage.getItem('notifications');
const notifications = stored ? JSON.parse(stored) : []; // const notifications = stored ? JSON.parse(stored) : [];
const newNotification = { // const newNotification = {
id: Date.now(), // id: Date.now(),
title: // title:
remoteMessage.notification?.title || // remoteMessage.notification?.title ||
remoteMessage.data?.title || // remoteMessage.data?.title ||
'Yangi bildirishnoma', // 'Yangi bildirishnoma',
message: // message:
remoteMessage.notification?.body || // remoteMessage.notification?.body ||
remoteMessage.data?.body || // remoteMessage.data?.body ||
'Matn yoq', // 'Matn yoq',
sentTime: remoteMessage.sentTime || Date.now(), // sentTime: remoteMessage.sentTime || Date.now(),
}; // };
await AsyncStorage.setItem( // await AsyncStorage.setItem(
'notifications', // 'notifications',
JSON.stringify([newNotification, ...notifications]), // JSON.stringify([newNotification, ...notifications]),
); // );
} catch (e) { // } catch (e) {
console.error('Notification saqlashda xato:', e); // console.error('Notification saqlashda xato:', e);
} // }
}; // };
async function onDisplayNotification(remoteMessage: any) { // async function onDisplayNotification(remoteMessage: any) {
const channelId = await notifee.createChannel({ // const channelId = await notifee.createChannel({
id: 'default', // id: 'default',
name: 'Umumiy bildirishnomalar', // name: 'Umumiy bildirishnomalar',
sound: 'default', // sound: 'default',
importance: AndroidImportance.HIGH, // importance: AndroidImportance.HIGH,
}); // });
await notifee.displayNotification({ // await notifee.displayNotification({
title: // title:
remoteMessage.notification?.title || // remoteMessage.notification?.title ||
remoteMessage.data?.title || // remoteMessage.data?.title ||
'Yangi xabar', // 'Yangi xabar',
body: // body:
remoteMessage.notification?.body || // remoteMessage.notification?.body ||
remoteMessage.data?.body || // remoteMessage.data?.body ||
'Matn yoq', // 'Matn yoq',
android: { // android: {
channelId, // channelId,
largeIcon: 'ic_launcher_foreground', // largeIcon: 'ic_launcher_foreground',
sound: 'default', // sound: 'default',
pressAction: { // pressAction: {
id: 'default', // id: 'default',
}, // },
}, // },
}); // });
} // }
async function requestNotificationPermission() { // async function requestNotificationPermission() {
if (Platform.OS === 'android' && Platform.Version >= 33) { // if (Platform.OS === 'android' && Platform.Version >= 33) {
const granted = await PermissionsAndroid.request( // const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS, // PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
); // );
console.log('POST_NOTIFICATIONS permission:', granted); // console.log('POST_NOTIFICATIONS permission:', granted);
} // }
} // }
export default function App() { export default function App() {
const [initialRoute, setInitialRoute] = useState<string | null>(null); const [initialRoute, setInitialRoute] = useState<string | null>(null);
const slideAnim = useRef(new Animated.Value(0)).current; const slideAnim = useRef(new Animated.Value(0)).current;
const [isSplashVisible, setIsSplashVisible] = useState(true); const [isSplashVisible, setIsSplashVisible] = useState(true);
useEffect(() => { // useEffect(() => {
requestNotificationPermission(); // requestNotificationPermission();
const messagingInstance = getMessaging(); // const messagingInstance = getMessaging();
const unsubscribe = onMessage(messagingInstance, async remoteMessage => { // const unsubscribe = onMessage(messagingInstance, async remoteMessage => {
console.log('Foreground message:', remoteMessage); // console.log('Foreground message:', remoteMessage);
await saveNotification(remoteMessage); // await saveNotification(remoteMessage);
await onDisplayNotification(remoteMessage); // await onDisplayNotification(remoteMessage);
}); // });
const unsubscribeOpened = onNotificationOpenedApp( // const unsubscribeOpened = onNotificationOpenedApp(
messagingInstance, // messagingInstance,
remoteMessage => { // remoteMessage => {
console.log('Backgrounddan ochildi:', remoteMessage); // console.log('Backgrounddan ochildi:', remoteMessage);
saveNotification(remoteMessage); // saveNotification(remoteMessage);
}, // },
); // );
(async () => { // (async () => {
const remoteMessage = await getInitialNotification(messagingInstance); // const remoteMessage = await getInitialNotification(messagingInstance);
if (remoteMessage) { // if (remoteMessage) {
console.log('Killeddan ochildi:', remoteMessage); // console.log('Killeddan ochildi:', remoteMessage);
saveNotification(remoteMessage); // saveNotification(remoteMessage);
} // }
})(); // })();
return () => { // return () => {
unsubscribe(); // unsubscribe();
unsubscribeOpened(); // unsubscribeOpened();
}; // };
}, []); // }, []);
useEffect(() => { useEffect(() => {
const initializeApp = async () => { const initializeApp = async () => {
@@ -214,34 +201,34 @@ export default function App() {
}, },
[], [],
); );
const [firebaseToken, setFirebseToken] = useState<{ // const [firebaseToken, setFirebseToken] = useState<{
fcmToken: string; // fcmToken: string;
deviceId: string; // deviceId: string;
deviceName: string; // deviceName: string;
} | null>(); // } | null>();
const app = getApp(); // const app = getApp();
const messaging = getMessaging(app); // const messaging = getMessaging(app);
const getDeviceData = async () => { // const getDeviceData = async () => {
try { // try {
const fcmToken = await getToken(messaging); // const fcmToken = await getToken(messaging);
return { // return {
fcmToken, // fcmToken,
deviceId: await DeviceInfo.getUniqueId(), // deviceId: await DeviceInfo.getUniqueId(),
deviceName: await DeviceInfo.getDeviceName(), // deviceName: await DeviceInfo.getDeviceName(),
}; // };
} catch (e) { // } catch (e) {
console.log('Xato:', e); // console.log('Xato:', e);
return null; // return null;
} // }
}; // };
console.log(firebaseToken); // console.log(firebaseToken);
useEffect(() => { // useEffect(() => {
getDeviceData().then(data => { // getDeviceData().then(data => {
setFirebseToken(data); // setFirebseToken(data);
}); // });
}, []); // }, []);
if (!initialRoute) return null; if (!initialRoute) return null;
@@ -285,9 +272,9 @@ export default function App() {
<Stack.Screen name="PaymentQrCode" component={PaymentQrCode} /> <Stack.Screen name="PaymentQrCode" component={PaymentQrCode} />
<Stack.Screen name="Profile" component={Profile} /> <Stack.Screen name="Profile" component={Profile} />
<Stack.Screen name="Settings" component={Settings} /> <Stack.Screen name="Settings" component={Settings} />
{Platform.OS === 'android' && ( {/* {Platform.OS === 'android' && (
<Stack.Screen name="Notifications" component={Notifications} /> <Stack.Screen name="Notifications" component={Notifications} />
)} )} */}
<Stack.Screen name="Warehouses" component={Warehouses} /> <Stack.Screen name="Warehouses" component={Warehouses} />
<Stack.Screen name="Support" component={Support} /> <Stack.Screen name="Support" component={Support} />
<Stack.Screen name="ListBranches" component={ListBranches} /> <Stack.Screen name="ListBranches" component={ListBranches} />

View File

@@ -1,41 +1,40 @@
/** /**
* @format * @format
*/ */
import notifee, { AndroidImportance } from '@notifee/react-native'; // import notifee, { AndroidImportance } from '@notifee/react-native';
import messaging from '@react-native-firebase/messaging'; // import messaging from '@react-native-firebase/messaging';
import { AppRegistry } from 'react-native'; import { AppRegistry } from 'react-native';
import App from './App'; import App from './App';
import { name as appName } from './app.json'; import { name as appName } from './app.json';
// 📌 Background/Killed xabarlarni ushlash // messaging().setBackgroundMessageHandler(async remoteMessage => {
messaging().setBackgroundMessageHandler(async remoteMessage => { // console.log('Background message:', remoteMessage);
console.log('Background message:', remoteMessage);
const channelId = await notifee.createChannel({ // const channelId = await notifee.createChannel({
id: 'default', // id: 'default',
name: 'Umumiy bildirishnomalar', // name: 'Umumiy bildirishnomalar',
sound: 'default', // sound: 'default',
importance: AndroidImportance.HIGH, // importance: AndroidImportance.HIGH,
}); // });
await notifee.displayNotification({ // await notifee.displayNotification({
title: // title:
remoteMessage.notification?.title || // remoteMessage.notification?.title ||
remoteMessage.data?.title || // remoteMessage.data?.title ||
'Yangi xabar', // 'Yangi xabar',
body: // body:
remoteMessage.notification?.body || // remoteMessage.notification?.body ||
remoteMessage.data?.body || // remoteMessage.data?.body ||
'Matn yoq', // 'Matn yoq',
android: { // android: {
channelId, // channelId,
largeIcon: 'ic_launcher_foreground', // largeIcon: 'ic_launcher_foreground',
sound: 'default', // sound: 'default',
pressAction: { // pressAction: {
id: 'default', // id: 'default',
}, // },
}, // },
}); // });
}); // });
AppRegistry.registerComponent(appName, () => App); AppRegistry.registerComponent(appName, () => App);

1091
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -18,8 +18,6 @@
"@react-native-async-storage/async-storage": "^2.2.0", "@react-native-async-storage/async-storage": "^2.2.0",
"@react-native-clipboard/clipboard": "^1.16.3", "@react-native-clipboard/clipboard": "^1.16.3",
"@react-native-community/datetimepicker": "^8.4.2", "@react-native-community/datetimepicker": "^8.4.2",
"@react-native-firebase/app": "^23.2.0",
"@react-native-firebase/messaging": "^23.2.0",
"@react-navigation/native": "^7.1.17", "@react-navigation/native": "^7.1.17",
"@react-navigation/native-stack": "^7.3.25", "@react-navigation/native-stack": "^7.3.25",
"@tanstack/react-query": "^5.84.2", "@tanstack/react-query": "^5.84.2",

View File

@@ -5,7 +5,6 @@ import {
Dimensions, Dimensions,
Image, Image,
Linking, Linking,
Platform,
StyleSheet, StyleSheet,
TouchableOpacity, TouchableOpacity,
View, View,
@@ -13,7 +12,6 @@ import {
import AppLink from 'react-native-app-link'; import AppLink from 'react-native-app-link';
import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { useSafeAreaInsets } from 'react-native-safe-area-context';
import Logo from 'screens/../../assets/bootsplash/logo.png'; import Logo from 'screens/../../assets/bootsplash/logo.png';
import Bell from 'svg/Bell';
import Instagram from 'svg/Instagram'; import Instagram from 'svg/Instagram';
import Telegram from 'svg/Telegram'; import Telegram from 'svg/Telegram';
import AppText from './AppText'; import AppText from './AppText';
@@ -97,14 +95,13 @@ const Navbar = () => {
size={iconSizes.facebook} size={iconSizes.facebook}
/> />
</TouchableOpacity> */} </TouchableOpacity> */}
{Platform.OS === 'android' && ( {/* {Platform.OS === 'android' && (
<TouchableOpacity <TouchableOpacity
onPress={() => navigation.navigate('Notifications')} onPress={() => navigation.navigate('Notifications')}
> >
<Bell color="#fff" width={24} height={24} /> <Bell color="#fff" width={24} height={24} />
{/* <View style={styles.bellDot} /> */}
</TouchableOpacity> </TouchableOpacity>
)} )} */}
</View> </View>
</View> </View>

View File

@@ -1,6 +1,4 @@
import AsyncStorage from '@react-native-async-storage/async-storage'; import AsyncStorage from '@react-native-async-storage/async-storage';
import { getApp } from '@react-native-firebase/app';
import { getMessaging, getToken } from '@react-native-firebase/messaging';
import { useNavigation } from '@react-navigation/native'; import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { useMutation } from '@tanstack/react-query'; import { useMutation } from '@tanstack/react-query';
@@ -20,7 +18,6 @@ import {
TouchableOpacity, TouchableOpacity,
View, View,
} from 'react-native'; } from 'react-native';
import DeviceInfo from 'react-native-device-info';
import { SafeAreaView } from 'react-native-safe-area-context'; import { SafeAreaView } from 'react-native-safe-area-context';
import Logo from 'screens/../../assets/bootsplash/logo_512.png'; import Logo from 'screens/../../assets/bootsplash/logo_512.png';
import LanguageSelector from 'screens/auth/select-language/SelectLang'; import LanguageSelector from 'screens/auth/select-language/SelectLang';
@@ -39,11 +36,11 @@ const OTP_LENGTH = 4;
const Confirm = () => { const Confirm = () => {
const navigation = useNavigation<VerificationCodeScreenNavigationProp>(); const navigation = useNavigation<VerificationCodeScreenNavigationProp>();
const { t } = useTranslation(); const { t } = useTranslation();
const [firebaseToken, setFirebseToken] = useState<{ // const [firebaseToken, setFirebseToken] = useState<{
fcmToken: string; // fcmToken: string;
deviceId: string; // deviceId: string;
deviceName: string; // deviceName: string;
} | null>(); // } | null>();
const [code, setCode] = useState<string[]>(new Array(OTP_LENGTH).fill('')); const [code, setCode] = useState<string[]>(new Array(OTP_LENGTH).fill(''));
const [timer, setTimer] = useState(60); const [timer, setTimer] = useState(60);
const [errorConfirm, setErrorConfirm] = useState<string | null>(null); const [errorConfirm, setErrorConfirm] = useState<string | null>(null);
@@ -51,28 +48,28 @@ const Confirm = () => {
const inputRefs = useRef<Array<TextInput | null>>([]); const inputRefs = useRef<Array<TextInput | null>>([]);
const { phoneNumber } = useUserStore(state => state); const { phoneNumber } = useUserStore(state => state);
const app = getApp(); // const app = getApp();
const messaging = getMessaging(app); // const messaging = getMessaging(app);
const getDeviceData = async () => { // const getDeviceData = async () => {
try { // try {
const fcmToken = await getToken(messaging); // const fcmToken = await getToken(messaging);
return { // return {
fcmToken, // fcmToken,
deviceId: await DeviceInfo.getUniqueId(), // deviceId: await DeviceInfo.getUniqueId(),
deviceName: await DeviceInfo.getDeviceName(), // deviceName: await DeviceInfo.getDeviceName(),
}; // };
} catch (e) { // } catch (e) {
console.log('Xato:', e); // console.log('Xato:', e);
return null; // return null;
} // }
}; // };
useEffect(() => { // useEffect(() => {
getDeviceData().then(data => { // getDeviceData().then(data => {
setFirebseToken(data); // setFirebseToken(data);
}); // });
}, []); // }, []);
const { mutate, isPending } = useMutation({ const { mutate, isPending } = useMutation({
mutationFn: (payload: otpPayload) => authApi.verifyOtp(payload), mutationFn: (payload: otpPayload) => authApi.verifyOtp(payload),
@@ -139,16 +136,14 @@ const Confirm = () => {
const handleVerifyCode = () => { const handleVerifyCode = () => {
const enteredCode = code.join(''); const enteredCode = code.join('');
if (firebaseToken) {
mutate({ mutate({
phoneNumber, phoneNumber,
otp: enteredCode, otp: enteredCode,
otpType: 'LOGIN', otpType: 'LOGIN',
deviceId: firebaseToken.deviceId, deviceId: '',
deviceName: firebaseToken.deviceName, deviceName: '',
fcmToken: firebaseToken.fcmToken, fcmToken: '',
}); });
}
}; };
return ( return (

View File

@@ -1,6 +1,4 @@
import { zodResolver } from '@hookform/resolvers/zod'; import { zodResolver } from '@hookform/resolvers/zod';
import { getApp } from '@react-native-firebase/app';
import { getMessaging, getToken } from '@react-native-firebase/messaging';
import { useNavigation } from '@react-navigation/native'; import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { useMutation, useQuery } from '@tanstack/react-query'; import { useMutation, useQuery } from '@tanstack/react-query';
@@ -9,13 +7,7 @@ import { loginPayload } from 'api/auth/type';
import { Branch, branchApi } from 'api/branch'; import { Branch, branchApi } from 'api/branch';
import AppText from 'components/AppText'; import AppText from 'components/AppText';
import formatPhone from 'helpers/formatPhone'; import formatPhone from 'helpers/formatPhone';
import React, { import React, { useCallback, useMemo, useRef, useState } from 'react';
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import { Controller, useForm } from 'react-hook-form'; import { Controller, useForm } from 'react-hook-form';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { import {
@@ -28,7 +20,6 @@ import {
TouchableOpacity, TouchableOpacity,
View, View,
} from 'react-native'; } from 'react-native';
import DeviceInfo from 'react-native-device-info';
import { SafeAreaView } from 'react-native-safe-area-context'; import { SafeAreaView } from 'react-native-safe-area-context';
import Logo from 'screens/../../assets/bootsplash/logo_512.png'; import Logo from 'screens/../../assets/bootsplash/logo_512.png';
import { LoginFormType, loginSchema } from 'screens/auth/login/lib/form'; import { LoginFormType, loginSchema } from 'screens/auth/login/lib/form';
@@ -59,36 +50,36 @@ const Login = () => {
queryKey: ['branchList'], queryKey: ['branchList'],
queryFn: branchApi.branchList, queryFn: branchApi.branchList,
}); });
const [firebaseToken, setFirebseToken] = useState<{ // const [firebaseToken, setFirebseToken] = useState<{
fcmToken: string; // fcmToken: string;
deviceId: string; // deviceId: string;
deviceName: string; // deviceName: string;
deviceType: string; // deviceType: string;
} | null>(); // } | null>();
const app = getApp(); // const app = getApp();
const messaging = getMessaging(app); // const messaging = getMessaging(app);
const getDeviceData = async () => { // const getDeviceData = async () => {
try { // try {
const fcmToken = await getToken(messaging); // const fcmToken = await getToken(messaging);
return { // return {
fcmToken, // fcmToken,
deviceId: await DeviceInfo.getUniqueId(), // deviceId: await DeviceInfo.getUniqueId(),
deviceName: await DeviceInfo.getDeviceName(), // deviceName: await DeviceInfo.getDeviceName(),
deviceType: await DeviceInfo.getDeviceType(), // deviceType: await DeviceInfo.getDeviceType(),
}; // };
} catch (e) { // } catch (e) {
console.log('Xato:', e); // console.log('Xato:', e);
return null; // return null;
} // }
}; // };
useEffect(() => { // useEffect(() => {
getDeviceData().then(data => { // getDeviceData().then(data => {
setFirebseToken(data); // setFirebseToken(data);
}); // });
}, []); // }, []);
const { mutate, isPending } = useMutation({ const { mutate, isPending } = useMutation({
mutationFn: (payload: loginPayload) => authApi.login(payload), mutationFn: (payload: loginPayload) => authApi.login(payload),
@@ -123,10 +114,10 @@ const Login = () => {
passportSerial: `${data.passportSeriya.toUpperCase()}${ passportSerial: `${data.passportSeriya.toUpperCase()}${
data.passportNumber data.passportNumber
}`, }`,
fcmToken: firebaseToken?.fcmToken || '', fcmToken: '',
deviceId: firebaseToken?.deviceId || '', deviceId: '',
deviceType: firebaseToken?.deviceType || '', deviceType: '',
deviceName: firebaseToken?.deviceName || '', deviceName: '',
}); });
// navigation.navigate('Login-Confirm'); // navigation.navigate('Login-Confirm');
setUser({ setUser({

View File

@@ -1,6 +1,6 @@
import AsyncStorage from '@react-native-async-storage/async-storage'; import AsyncStorage from '@react-native-async-storage/async-storage';
import { getApp } from '@react-native-firebase/app'; // import { getApp } from '@react-native-firebase/app';
import { getMessaging, getToken } from '@react-native-firebase/messaging'; // import { getMessaging, getToken } from '@react-native-firebase/messaging';
import { useNavigation } from '@react-navigation/native'; import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { useMutation } from '@tanstack/react-query'; import { useMutation } from '@tanstack/react-query';
@@ -20,7 +20,6 @@ import {
TouchableOpacity, TouchableOpacity,
View, View,
} from 'react-native'; } from 'react-native';
import DeviceInfo from 'react-native-device-info';
import { SafeAreaView } from 'react-native-safe-area-context'; import { SafeAreaView } from 'react-native-safe-area-context';
import Logo from 'screens/../../assets/bootsplash/logo_512.png'; import Logo from 'screens/../../assets/bootsplash/logo_512.png';
import { useModalStore } from 'screens/auth/registeration/lib/modalStore'; import { useModalStore } from 'screens/auth/registeration/lib/modalStore';
@@ -50,34 +49,35 @@ const Confirm = ({
const [errorConfirm, setErrorConfirm] = useState<string | null>(null); const [errorConfirm, setErrorConfirm] = useState<string | null>(null);
const inputRefs = useRef<Array<TextInput | null>>([]); const inputRefs = useRef<Array<TextInput | null>>([]);
const { phoneNumber } = useUserStore(state => state); const { phoneNumber } = useUserStore(state => state);
const [firebaseToken, setFirebseToken] = useState<{ // const [firebaseToken, setFirebseToken] = useState<{
fcmToken: string; // fcmToken: string;
deviceId: string; // deviceId: string;
deviceName: string; // deviceName: string;
} | null>(); // } | null>();
const app = getApp(); // const app = getApp();
const messaging = getMessaging(app); // const messaging = getMessaging(app);
const getDeviceData = async () => { // const getDeviceData = async () => {
try { // try {
const fcmToken = await getToken(messaging); // const fcmToken = await getToken(messaging);
return { // return {
fcmToken, // fcmToken,
deviceId: await DeviceInfo.getUniqueId(), // deviceId: await DeviceInfo.getUniqueId(),
deviceName: await DeviceInfo.getDeviceName(), // deviceName: await DeviceInfo.getDeviceName(),
}; // };
} catch (e) { // } catch (e) {
console.log('Xato:', e); // console.log('Xato:', e);
return null; // return null;
} // }
}; // };
// useEffect(() => {
// getDeviceData().then(data => {
// setFirebseToken(data);
// });
// }, []);
useEffect(() => {
getDeviceData().then(data => {
setFirebseToken(data);
});
}, []);
const { mutate, isPending } = useMutation({ const { mutate, isPending } = useMutation({
mutationFn: (payload: otpPayload) => authApi.verifyOtp(payload), mutationFn: (payload: otpPayload) => authApi.verifyOtp(payload),
onSuccess: async res => { onSuccess: async res => {
@@ -149,16 +149,15 @@ const Confirm = ({
const handleVerifyCode = () => { const handleVerifyCode = () => {
const enteredCode = code.join(''); const enteredCode = code.join('');
if (firebaseToken) {
mutate({ mutate({
phoneNumber, phoneNumber,
otp: enteredCode, otp: enteredCode,
otpType: 'REGISTRATION', otpType: 'REGISTRATION',
deviceId: firebaseToken.deviceId, deviceId: '',
deviceName: firebaseToken.deviceName, deviceName: '',
fcmToken: firebaseToken.fcmToken, fcmToken: '',
}); });
}
}; };
return ( return (

View File

@@ -1,8 +1,8 @@
'use client'; 'use client';
import { zodResolver } from '@hookform/resolvers/zod'; import { zodResolver } from '@hookform/resolvers/zod';
import { getApp } from '@react-native-firebase/app'; // import { getApp } from '@react-native-firebase/app';
import { getMessaging, getToken } from '@react-native-firebase/messaging'; // import { getMessaging, getToken } from '@react-native-firebase/messaging';
import { import {
type RouteProp, type RouteProp,
useNavigation, useNavigation,
@@ -29,7 +29,6 @@ import {
TouchableOpacity, TouchableOpacity,
View, View,
} from 'react-native'; } from 'react-native';
import DeviceInfo from 'react-native-device-info';
import { SafeAreaView } from 'react-native-safe-area-context'; import { SafeAreaView } from 'react-native-safe-area-context';
import Logo from 'screens/../../assets/bootsplash/logo_512.png'; import Logo from 'screens/../../assets/bootsplash/logo_512.png';
import { import {
@@ -67,36 +66,36 @@ const FirstStep = ({ onNext }: { onNext: () => void }) => {
queryFn: branchApi.branchList, queryFn: branchApi.branchList,
}); });
const [firebaseToken, setFirebseToken] = useState<{ // const [firebaseToken, setFirebseToken] = useState<{
fcmToken: string; // fcmToken: string;
deviceId: string; // deviceId: string;
deviceName: string; // deviceName: string;
deviceType: string; // deviceType: string;
} | null>(); // } | null>();
const app = getApp(); // const app = getApp();
const messaging = getMessaging(app); // const messaging = getMessaging(app);
const getDeviceData = async () => { // const getDeviceData = async () => {
try { // try {
const fcmToken = await getToken(messaging); // const fcmToken = await getToken(messaging);
return { // return {
fcmToken, // fcmToken,
deviceId: await DeviceInfo.getUniqueId(), // deviceId: await DeviceInfo.getUniqueId(),
deviceName: await DeviceInfo.getDeviceName(), // deviceName: await DeviceInfo.getDeviceName(),
deviceType: await DeviceInfo.getDeviceType(), // deviceType: await DeviceInfo.getDeviceType(),
}; // };
} catch (e) { // } catch (e) {
console.log('Xato:', e); // console.log('Xato:', e);
return null; // return null;
} // }
}; // };
useEffect(() => { // useEffect(() => {
getDeviceData().then(data => { // getDeviceData().then(data => {
setFirebseToken(data); // setFirebseToken(data);
}); // });
}, []); // }, []);
const { mutate, isPending } = useMutation({ const { mutate, isPending } = useMutation({
mutationFn: (payload: registerPayload) => authApi.register(payload), mutationFn: (payload: registerPayload) => authApi.register(payload),
@@ -144,10 +143,10 @@ const FirstStep = ({ onNext }: { onNext: () => void }) => {
recommend: data.recommend, recommend: data.recommend,
branchId: data.branchId, branchId: data.branchId,
address: data.address, address: data.address,
fcmToken: firebaseToken?.fcmToken || '', fcmToken: '',
deviceId: firebaseToken?.deviceId || '', deviceId: '',
deviceType: firebaseToken?.deviceType || '', deviceType: '',
deviceName: firebaseToken?.deviceId || '', deviceName: '',
}); });
}; };

View File

@@ -7,14 +7,12 @@ import { useTranslation } from 'react-i18next';
import { import {
Alert, Alert,
Linking, Linking,
Platform,
StyleSheet, StyleSheet,
TouchableOpacity, TouchableOpacity,
View, View,
} from 'react-native'; } from 'react-native';
import AppLink from 'react-native-app-link'; import AppLink from 'react-native-app-link';
import ArrowRightUnderline from 'svg/ArrowRightUnderline'; import ArrowRightUnderline from 'svg/ArrowRightUnderline';
import Bell from 'svg/Bell';
import Location from 'svg/Location'; import Location from 'svg/Location';
import Logout from 'svg/LogOut'; import Logout from 'svg/LogOut';
import Setting from 'svg/Setting'; import Setting from 'svg/Setting';
@@ -80,7 +78,7 @@ const ProfilePages = (props: componentNameProps) => {
</View> </View>
<ArrowRightUnderline color="#373737" width={24} height={24} /> <ArrowRightUnderline color="#373737" width={24} height={24} />
</TouchableOpacity> </TouchableOpacity>
{Platform.OS === 'android' && ( {/* {Platform.OS === 'android' && (
<TouchableOpacity <TouchableOpacity
style={[ style={[
styles.card, styles.card,
@@ -94,7 +92,7 @@ const ProfilePages = (props: componentNameProps) => {
</View> </View>
<ArrowRightUnderline color="#373737" width={24} height={24} /> <ArrowRightUnderline color="#373737" width={24} height={24} />
</TouchableOpacity> </TouchableOpacity>
)} )} */}
<TouchableOpacity <TouchableOpacity
style={[ style={[
styles.card, styles.card,

View File

@@ -1,14 +1,14 @@
import { initializeApp } from '@react-native-firebase/app'; // import { initializeApp } from '@react-native-firebase/app';
import { getMessaging } from '@react-native-firebase/messaging'; // import { getMessaging } from '@react-native-firebase/messaging';
const firebaseConfig = { // const firebaseConfig = {
apiKey: 'AIzaSyBEwWi1TuZBNj2hkFGGIaWZNNDCoiC__lE', // apiKey: 'AIzaSyBEwWi1TuZBNj2hkFGGIaWZNNDCoiC__lE',
authDomain: 'cpcargo-aee14.firebaseapp.com', // authDomain: 'cpcargo-aee14.firebaseapp.com',
projectId: 'cpcargo-aee14', // projectId: 'cpcargo-aee14',
storageBucket: 'cpcargo-aee14.firebasestorage.app', // storageBucket: 'cpcargo-aee14.firebasestorage.app',
messagingSenderId: '1030089382290', // messagingSenderId: '1030089382290',
appId: '1:1030089382290:android:668f0669ad4ac3f74dc94b', // appId: '1:1030089382290:android:668f0669ad4ac3f74dc94b',
}; // };
export const firebaseApp = initializeApp(firebaseConfig); // export const firebaseApp = initializeApp(firebaseConfig);
export const messaging = getMessaging(await firebaseApp); // export const messaging = getMessaging(await firebaseApp);

View File

@@ -1,16 +1,15 @@
// firebase.js // firebase.js
import { initializeApp } from '@react-native-firebase/app'; // import { initializeApp } from '@react-native-firebase/app';
const firebaseConfig = { // const firebaseConfig = {
apiKey: 'AIzaSyBnFzHK6XAjxzcQAsg0hFbeRcon8ZMDvVw', // api_key → current_key // apiKey: 'AIzaSyBnFzHK6XAjxzcQAsg0hFbeRcon8ZMDvVw',
authDomain: 'cpcargo-77d93.firebaseapp.com', // Firebase web SDK uchun qoshimcha, yoq bolsa qoldirish mumkin // authDomain: 'cpcargo-77d93.firebaseapp.com',
projectId: 'cpcargo-77d93', // project_info → project_id // projectId: 'cpcargo-77d93',
storageBucket: 'cpcargo-77d93.firebasestorage.app', // project_info → storage_bucket // storageBucket: 'cpcargo-77d93.firebasestorage.app',
messagingSenderId: '628048576398', // project_info → project_number // messagingSenderId: '628048576398',
appId: '1:628048576398:android:f93293c00f463267a92edf', // client_info → mobilesdk_app_id // appId: '1:628048576398:android:f93293c00f463267a92edf',
}; // };
// Firebase ilovasini initialize qilish // const app = initializeApp(firebaseConfig);
const app = initializeApp(firebaseConfig);
export default app; // export default app;