delete firebase
This commit is contained in:
239
App.tsx
239
App.tsx
@@ -13,8 +13,6 @@ import {
|
||||
Animated,
|
||||
Dimensions,
|
||||
LogBox,
|
||||
PermissionsAndroid,
|
||||
Platform,
|
||||
StatusBar,
|
||||
StyleSheet,
|
||||
View,
|
||||
@@ -22,16 +20,6 @@ import {
|
||||
import Toast from 'react-native-toast-message';
|
||||
|
||||
// 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 Confirm from 'screens/auth/login/ui/Confirm';
|
||||
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 Passport from 'screens/passport/myPassport/ui/Passport';
|
||||
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 Settings from 'screens/profile/settings/ui/Settings';
|
||||
import SettingsLock from 'screens/profile/settings/ui/SettingsLock';
|
||||
@@ -68,107 +55,107 @@ const Stack = createNativeStackNavigator();
|
||||
const screenWidth = Dimensions.get('window').width;
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
const saveNotification = async (remoteMessage: any) => {
|
||||
try {
|
||||
const stored = await AsyncStorage.getItem('notifications');
|
||||
const notifications = stored ? JSON.parse(stored) : [];
|
||||
// const saveNotification = async (remoteMessage: any) => {
|
||||
// try {
|
||||
// const stored = await AsyncStorage.getItem('notifications');
|
||||
// const notifications = stored ? JSON.parse(stored) : [];
|
||||
|
||||
const newNotification = {
|
||||
id: Date.now(),
|
||||
title:
|
||||
remoteMessage.notification?.title ||
|
||||
remoteMessage.data?.title ||
|
||||
'Yangi bildirishnoma',
|
||||
message:
|
||||
remoteMessage.notification?.body ||
|
||||
remoteMessage.data?.body ||
|
||||
'Matn yo‘q',
|
||||
sentTime: remoteMessage.sentTime || Date.now(),
|
||||
};
|
||||
// const newNotification = {
|
||||
// id: Date.now(),
|
||||
// title:
|
||||
// remoteMessage.notification?.title ||
|
||||
// remoteMessage.data?.title ||
|
||||
// 'Yangi bildirishnoma',
|
||||
// message:
|
||||
// remoteMessage.notification?.body ||
|
||||
// remoteMessage.data?.body ||
|
||||
// 'Matn yo‘q',
|
||||
// sentTime: remoteMessage.sentTime || Date.now(),
|
||||
// };
|
||||
|
||||
await AsyncStorage.setItem(
|
||||
'notifications',
|
||||
JSON.stringify([newNotification, ...notifications]),
|
||||
);
|
||||
} catch (e) {
|
||||
console.error('Notification saqlashda xato:', e);
|
||||
}
|
||||
};
|
||||
// await AsyncStorage.setItem(
|
||||
// 'notifications',
|
||||
// JSON.stringify([newNotification, ...notifications]),
|
||||
// );
|
||||
// } catch (e) {
|
||||
// console.error('Notification saqlashda xato:', e);
|
||||
// }
|
||||
// };
|
||||
|
||||
async function onDisplayNotification(remoteMessage: any) {
|
||||
const channelId = await notifee.createChannel({
|
||||
id: 'default',
|
||||
name: 'Umumiy bildirishnomalar',
|
||||
sound: 'default',
|
||||
importance: AndroidImportance.HIGH,
|
||||
});
|
||||
// async function onDisplayNotification(remoteMessage: any) {
|
||||
// const channelId = await notifee.createChannel({
|
||||
// id: 'default',
|
||||
// name: 'Umumiy bildirishnomalar',
|
||||
// sound: 'default',
|
||||
// importance: AndroidImportance.HIGH,
|
||||
// });
|
||||
|
||||
await notifee.displayNotification({
|
||||
title:
|
||||
remoteMessage.notification?.title ||
|
||||
remoteMessage.data?.title ||
|
||||
'Yangi xabar',
|
||||
body:
|
||||
remoteMessage.notification?.body ||
|
||||
remoteMessage.data?.body ||
|
||||
'Matn yo‘q',
|
||||
android: {
|
||||
channelId,
|
||||
largeIcon: 'ic_launcher_foreground',
|
||||
sound: 'default',
|
||||
pressAction: {
|
||||
id: 'default',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
// await notifee.displayNotification({
|
||||
// title:
|
||||
// remoteMessage.notification?.title ||
|
||||
// remoteMessage.data?.title ||
|
||||
// 'Yangi xabar',
|
||||
// body:
|
||||
// remoteMessage.notification?.body ||
|
||||
// remoteMessage.data?.body ||
|
||||
// 'Matn yo‘q',
|
||||
// android: {
|
||||
// channelId,
|
||||
// largeIcon: 'ic_launcher_foreground',
|
||||
// sound: 'default',
|
||||
// pressAction: {
|
||||
// id: 'default',
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
async function requestNotificationPermission() {
|
||||
if (Platform.OS === 'android' && Platform.Version >= 33) {
|
||||
const granted = await PermissionsAndroid.request(
|
||||
PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
|
||||
);
|
||||
console.log('POST_NOTIFICATIONS permission:', granted);
|
||||
}
|
||||
}
|
||||
// async function requestNotificationPermission() {
|
||||
// if (Platform.OS === 'android' && Platform.Version >= 33) {
|
||||
// const granted = await PermissionsAndroid.request(
|
||||
// PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
|
||||
// );
|
||||
// console.log('POST_NOTIFICATIONS permission:', granted);
|
||||
// }
|
||||
// }
|
||||
|
||||
export default function App() {
|
||||
const [initialRoute, setInitialRoute] = useState<string | null>(null);
|
||||
const slideAnim = useRef(new Animated.Value(0)).current;
|
||||
const [isSplashVisible, setIsSplashVisible] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
requestNotificationPermission();
|
||||
// useEffect(() => {
|
||||
// requestNotificationPermission();
|
||||
|
||||
const messagingInstance = getMessaging();
|
||||
// const messagingInstance = getMessaging();
|
||||
|
||||
const unsubscribe = onMessage(messagingInstance, async remoteMessage => {
|
||||
console.log('Foreground message:', remoteMessage);
|
||||
await saveNotification(remoteMessage);
|
||||
await onDisplayNotification(remoteMessage);
|
||||
});
|
||||
// const unsubscribe = onMessage(messagingInstance, async remoteMessage => {
|
||||
// console.log('Foreground message:', remoteMessage);
|
||||
// await saveNotification(remoteMessage);
|
||||
// await onDisplayNotification(remoteMessage);
|
||||
// });
|
||||
|
||||
const unsubscribeOpened = onNotificationOpenedApp(
|
||||
messagingInstance,
|
||||
remoteMessage => {
|
||||
console.log('Backgrounddan ochildi:', remoteMessage);
|
||||
saveNotification(remoteMessage);
|
||||
},
|
||||
);
|
||||
// const unsubscribeOpened = onNotificationOpenedApp(
|
||||
// messagingInstance,
|
||||
// remoteMessage => {
|
||||
// console.log('Backgrounddan ochildi:', remoteMessage);
|
||||
// saveNotification(remoteMessage);
|
||||
// },
|
||||
// );
|
||||
|
||||
(async () => {
|
||||
const remoteMessage = await getInitialNotification(messagingInstance);
|
||||
if (remoteMessage) {
|
||||
console.log('Killeddan ochildi:', remoteMessage);
|
||||
saveNotification(remoteMessage);
|
||||
}
|
||||
})();
|
||||
// (async () => {
|
||||
// const remoteMessage = await getInitialNotification(messagingInstance);
|
||||
// if (remoteMessage) {
|
||||
// console.log('Killeddan ochildi:', remoteMessage);
|
||||
// saveNotification(remoteMessage);
|
||||
// }
|
||||
// })();
|
||||
|
||||
return () => {
|
||||
unsubscribe();
|
||||
unsubscribeOpened();
|
||||
};
|
||||
}, []);
|
||||
// return () => {
|
||||
// unsubscribe();
|
||||
// unsubscribeOpened();
|
||||
// };
|
||||
// }, []);
|
||||
|
||||
useEffect(() => {
|
||||
const initializeApp = async () => {
|
||||
@@ -214,34 +201,34 @@ export default function App() {
|
||||
},
|
||||
[],
|
||||
);
|
||||
const [firebaseToken, setFirebseToken] = useState<{
|
||||
fcmToken: string;
|
||||
deviceId: string;
|
||||
deviceName: string;
|
||||
} | null>();
|
||||
const app = getApp();
|
||||
const messaging = getMessaging(app);
|
||||
// const [firebaseToken, setFirebseToken] = useState<{
|
||||
// fcmToken: string;
|
||||
// deviceId: string;
|
||||
// deviceName: string;
|
||||
// } | null>();
|
||||
// const app = getApp();
|
||||
// const messaging = getMessaging(app);
|
||||
|
||||
const getDeviceData = async () => {
|
||||
try {
|
||||
const fcmToken = await getToken(messaging);
|
||||
return {
|
||||
fcmToken,
|
||||
deviceId: await DeviceInfo.getUniqueId(),
|
||||
deviceName: await DeviceInfo.getDeviceName(),
|
||||
};
|
||||
} catch (e) {
|
||||
console.log('Xato:', e);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
console.log(firebaseToken);
|
||||
// const getDeviceData = async () => {
|
||||
// try {
|
||||
// const fcmToken = await getToken(messaging);
|
||||
// return {
|
||||
// fcmToken,
|
||||
// deviceId: await DeviceInfo.getUniqueId(),
|
||||
// deviceName: await DeviceInfo.getDeviceName(),
|
||||
// };
|
||||
// } catch (e) {
|
||||
// console.log('Xato:', e);
|
||||
// return null;
|
||||
// }
|
||||
// };
|
||||
// console.log(firebaseToken);
|
||||
|
||||
useEffect(() => {
|
||||
getDeviceData().then(data => {
|
||||
setFirebseToken(data);
|
||||
});
|
||||
}, []);
|
||||
// useEffect(() => {
|
||||
// getDeviceData().then(data => {
|
||||
// setFirebseToken(data);
|
||||
// });
|
||||
// }, []);
|
||||
|
||||
if (!initialRoute) return null;
|
||||
|
||||
@@ -285,9 +272,9 @@ export default function App() {
|
||||
<Stack.Screen name="PaymentQrCode" component={PaymentQrCode} />
|
||||
<Stack.Screen name="Profile" component={Profile} />
|
||||
<Stack.Screen name="Settings" component={Settings} />
|
||||
{Platform.OS === 'android' && (
|
||||
{/* {Platform.OS === 'android' && (
|
||||
<Stack.Screen name="Notifications" component={Notifications} />
|
||||
)}
|
||||
)} */}
|
||||
<Stack.Screen name="Warehouses" component={Warehouses} />
|
||||
<Stack.Screen name="Support" component={Support} />
|
||||
<Stack.Screen name="ListBranches" component={ListBranches} />
|
||||
|
||||
59
index.js
59
index.js
@@ -1,41 +1,40 @@
|
||||
/**
|
||||
* @format
|
||||
*/
|
||||
import notifee, { AndroidImportance } from '@notifee/react-native';
|
||||
import messaging from '@react-native-firebase/messaging';
|
||||
// import notifee, { AndroidImportance } from '@notifee/react-native';
|
||||
// import messaging from '@react-native-firebase/messaging';
|
||||
import { AppRegistry } from 'react-native';
|
||||
import App from './App';
|
||||
import { name as appName } from './app.json';
|
||||
|
||||
// 📌 Background/Killed xabarlarni ushlash
|
||||
messaging().setBackgroundMessageHandler(async remoteMessage => {
|
||||
console.log('Background message:', remoteMessage);
|
||||
// messaging().setBackgroundMessageHandler(async remoteMessage => {
|
||||
// console.log('Background message:', remoteMessage);
|
||||
|
||||
const channelId = await notifee.createChannel({
|
||||
id: 'default',
|
||||
name: 'Umumiy bildirishnomalar',
|
||||
sound: 'default',
|
||||
importance: AndroidImportance.HIGH,
|
||||
});
|
||||
// const channelId = await notifee.createChannel({
|
||||
// id: 'default',
|
||||
// name: 'Umumiy bildirishnomalar',
|
||||
// sound: 'default',
|
||||
// importance: AndroidImportance.HIGH,
|
||||
// });
|
||||
|
||||
await notifee.displayNotification({
|
||||
title:
|
||||
remoteMessage.notification?.title ||
|
||||
remoteMessage.data?.title ||
|
||||
'Yangi xabar',
|
||||
body:
|
||||
remoteMessage.notification?.body ||
|
||||
remoteMessage.data?.body ||
|
||||
'Matn yo‘q',
|
||||
android: {
|
||||
channelId,
|
||||
largeIcon: 'ic_launcher_foreground',
|
||||
sound: 'default',
|
||||
pressAction: {
|
||||
id: 'default',
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
// await notifee.displayNotification({
|
||||
// title:
|
||||
// remoteMessage.notification?.title ||
|
||||
// remoteMessage.data?.title ||
|
||||
// 'Yangi xabar',
|
||||
// body:
|
||||
// remoteMessage.notification?.body ||
|
||||
// remoteMessage.data?.body ||
|
||||
// 'Matn yo‘q',
|
||||
// android: {
|
||||
// channelId,
|
||||
// largeIcon: 'ic_launcher_foreground',
|
||||
// sound: 'default',
|
||||
// pressAction: {
|
||||
// id: 'default',
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
|
||||
AppRegistry.registerComponent(appName, () => App);
|
||||
|
||||
1091
package-lock.json
generated
1091
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -18,8 +18,6 @@
|
||||
"@react-native-async-storage/async-storage": "^2.2.0",
|
||||
"@react-native-clipboard/clipboard": "^1.16.3",
|
||||
"@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-stack": "^7.3.25",
|
||||
"@tanstack/react-query": "^5.84.2",
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
Dimensions,
|
||||
Image,
|
||||
Linking,
|
||||
Platform,
|
||||
StyleSheet,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
@@ -13,7 +12,6 @@ import {
|
||||
import AppLink from 'react-native-app-link';
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
import Logo from 'screens/../../assets/bootsplash/logo.png';
|
||||
import Bell from 'svg/Bell';
|
||||
import Instagram from 'svg/Instagram';
|
||||
import Telegram from 'svg/Telegram';
|
||||
import AppText from './AppText';
|
||||
@@ -97,14 +95,13 @@ const Navbar = () => {
|
||||
size={iconSizes.facebook}
|
||||
/>
|
||||
</TouchableOpacity> */}
|
||||
{Platform.OS === 'android' && (
|
||||
{/* {Platform.OS === 'android' && (
|
||||
<TouchableOpacity
|
||||
onPress={() => navigation.navigate('Notifications')}
|
||||
>
|
||||
<Bell color="#fff" width={24} height={24} />
|
||||
{/* <View style={styles.bellDot} /> */}
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
)} */}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
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 { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
@@ -20,7 +18,6 @@ import {
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import DeviceInfo from 'react-native-device-info';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
import Logo from 'screens/../../assets/bootsplash/logo_512.png';
|
||||
import LanguageSelector from 'screens/auth/select-language/SelectLang';
|
||||
@@ -39,11 +36,11 @@ const OTP_LENGTH = 4;
|
||||
const Confirm = () => {
|
||||
const navigation = useNavigation<VerificationCodeScreenNavigationProp>();
|
||||
const { t } = useTranslation();
|
||||
const [firebaseToken, setFirebseToken] = useState<{
|
||||
fcmToken: string;
|
||||
deviceId: string;
|
||||
deviceName: string;
|
||||
} | null>();
|
||||
// const [firebaseToken, setFirebseToken] = useState<{
|
||||
// fcmToken: string;
|
||||
// deviceId: string;
|
||||
// deviceName: string;
|
||||
// } | null>();
|
||||
const [code, setCode] = useState<string[]>(new Array(OTP_LENGTH).fill(''));
|
||||
const [timer, setTimer] = useState(60);
|
||||
const [errorConfirm, setErrorConfirm] = useState<string | null>(null);
|
||||
@@ -51,28 +48,28 @@ const Confirm = () => {
|
||||
const inputRefs = useRef<Array<TextInput | null>>([]);
|
||||
const { phoneNumber } = useUserStore(state => state);
|
||||
|
||||
const app = getApp();
|
||||
const messaging = getMessaging(app);
|
||||
// const app = getApp();
|
||||
// const messaging = getMessaging(app);
|
||||
|
||||
const getDeviceData = async () => {
|
||||
try {
|
||||
const fcmToken = await getToken(messaging);
|
||||
return {
|
||||
fcmToken,
|
||||
deviceId: await DeviceInfo.getUniqueId(),
|
||||
deviceName: await DeviceInfo.getDeviceName(),
|
||||
};
|
||||
} catch (e) {
|
||||
console.log('Xato:', e);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
// const getDeviceData = async () => {
|
||||
// try {
|
||||
// const fcmToken = await getToken(messaging);
|
||||
// return {
|
||||
// fcmToken,
|
||||
// deviceId: await DeviceInfo.getUniqueId(),
|
||||
// deviceName: await DeviceInfo.getDeviceName(),
|
||||
// };
|
||||
// } catch (e) {
|
||||
// console.log('Xato:', e);
|
||||
// return null;
|
||||
// }
|
||||
// };
|
||||
|
||||
useEffect(() => {
|
||||
getDeviceData().then(data => {
|
||||
setFirebseToken(data);
|
||||
});
|
||||
}, []);
|
||||
// useEffect(() => {
|
||||
// getDeviceData().then(data => {
|
||||
// setFirebseToken(data);
|
||||
// });
|
||||
// }, []);
|
||||
|
||||
const { mutate, isPending } = useMutation({
|
||||
mutationFn: (payload: otpPayload) => authApi.verifyOtp(payload),
|
||||
@@ -139,16 +136,14 @@ const Confirm = () => {
|
||||
|
||||
const handleVerifyCode = () => {
|
||||
const enteredCode = code.join('');
|
||||
if (firebaseToken) {
|
||||
mutate({
|
||||
phoneNumber,
|
||||
otp: enteredCode,
|
||||
otpType: 'LOGIN',
|
||||
deviceId: firebaseToken.deviceId,
|
||||
deviceName: firebaseToken.deviceName,
|
||||
fcmToken: firebaseToken.fcmToken,
|
||||
deviceId: '',
|
||||
deviceName: '',
|
||||
fcmToken: '',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
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 { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||
@@ -9,13 +7,7 @@ import { loginPayload } from 'api/auth/type';
|
||||
import { Branch, branchApi } from 'api/branch';
|
||||
import AppText from 'components/AppText';
|
||||
import formatPhone from 'helpers/formatPhone';
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
||||
import { Controller, useForm } from 'react-hook-form';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
@@ -28,7 +20,6 @@ import {
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import DeviceInfo from 'react-native-device-info';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
import Logo from 'screens/../../assets/bootsplash/logo_512.png';
|
||||
import { LoginFormType, loginSchema } from 'screens/auth/login/lib/form';
|
||||
@@ -59,36 +50,36 @@ const Login = () => {
|
||||
queryKey: ['branchList'],
|
||||
queryFn: branchApi.branchList,
|
||||
});
|
||||
const [firebaseToken, setFirebseToken] = useState<{
|
||||
fcmToken: string;
|
||||
deviceId: string;
|
||||
deviceName: string;
|
||||
deviceType: string;
|
||||
} | null>();
|
||||
// const [firebaseToken, setFirebseToken] = useState<{
|
||||
// fcmToken: string;
|
||||
// deviceId: string;
|
||||
// deviceName: string;
|
||||
// deviceType: string;
|
||||
// } | null>();
|
||||
|
||||
const app = getApp();
|
||||
const messaging = getMessaging(app);
|
||||
// const app = getApp();
|
||||
// const messaging = getMessaging(app);
|
||||
|
||||
const getDeviceData = async () => {
|
||||
try {
|
||||
const fcmToken = await getToken(messaging);
|
||||
return {
|
||||
fcmToken,
|
||||
deviceId: await DeviceInfo.getUniqueId(),
|
||||
deviceName: await DeviceInfo.getDeviceName(),
|
||||
deviceType: await DeviceInfo.getDeviceType(),
|
||||
};
|
||||
} catch (e) {
|
||||
console.log('Xato:', e);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
// const getDeviceData = async () => {
|
||||
// try {
|
||||
// const fcmToken = await getToken(messaging);
|
||||
// return {
|
||||
// fcmToken,
|
||||
// deviceId: await DeviceInfo.getUniqueId(),
|
||||
// deviceName: await DeviceInfo.getDeviceName(),
|
||||
// deviceType: await DeviceInfo.getDeviceType(),
|
||||
// };
|
||||
// } catch (e) {
|
||||
// console.log('Xato:', e);
|
||||
// return null;
|
||||
// }
|
||||
// };
|
||||
|
||||
useEffect(() => {
|
||||
getDeviceData().then(data => {
|
||||
setFirebseToken(data);
|
||||
});
|
||||
}, []);
|
||||
// useEffect(() => {
|
||||
// getDeviceData().then(data => {
|
||||
// setFirebseToken(data);
|
||||
// });
|
||||
// }, []);
|
||||
|
||||
const { mutate, isPending } = useMutation({
|
||||
mutationFn: (payload: loginPayload) => authApi.login(payload),
|
||||
@@ -123,10 +114,10 @@ const Login = () => {
|
||||
passportSerial: `${data.passportSeriya.toUpperCase()}${
|
||||
data.passportNumber
|
||||
}`,
|
||||
fcmToken: firebaseToken?.fcmToken || '',
|
||||
deviceId: firebaseToken?.deviceId || '',
|
||||
deviceType: firebaseToken?.deviceType || '',
|
||||
deviceName: firebaseToken?.deviceName || '',
|
||||
fcmToken: '',
|
||||
deviceId: '',
|
||||
deviceType: '',
|
||||
deviceName: '',
|
||||
});
|
||||
// navigation.navigate('Login-Confirm');
|
||||
setUser({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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 { getApp } from '@react-native-firebase/app';
|
||||
// import { getMessaging, getToken } from '@react-native-firebase/messaging';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
@@ -20,7 +20,6 @@ import {
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import DeviceInfo from 'react-native-device-info';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
import Logo from 'screens/../../assets/bootsplash/logo_512.png';
|
||||
import { useModalStore } from 'screens/auth/registeration/lib/modalStore';
|
||||
@@ -50,34 +49,35 @@ const Confirm = ({
|
||||
const [errorConfirm, setErrorConfirm] = useState<string | null>(null);
|
||||
const inputRefs = useRef<Array<TextInput | null>>([]);
|
||||
const { phoneNumber } = useUserStore(state => state);
|
||||
const [firebaseToken, setFirebseToken] = useState<{
|
||||
fcmToken: string;
|
||||
deviceId: string;
|
||||
deviceName: string;
|
||||
} | null>();
|
||||
// const [firebaseToken, setFirebseToken] = useState<{
|
||||
// fcmToken: string;
|
||||
// deviceId: string;
|
||||
// deviceName: string;
|
||||
// } | null>();
|
||||
|
||||
const app = getApp();
|
||||
const messaging = getMessaging(app);
|
||||
// const app = getApp();
|
||||
// const messaging = getMessaging(app);
|
||||
|
||||
const getDeviceData = async () => {
|
||||
try {
|
||||
const fcmToken = await getToken(messaging);
|
||||
return {
|
||||
fcmToken,
|
||||
deviceId: await DeviceInfo.getUniqueId(),
|
||||
deviceName: await DeviceInfo.getDeviceName(),
|
||||
};
|
||||
} catch (e) {
|
||||
console.log('Xato:', e);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
// const getDeviceData = async () => {
|
||||
// try {
|
||||
// const fcmToken = await getToken(messaging);
|
||||
// return {
|
||||
// fcmToken,
|
||||
// deviceId: await DeviceInfo.getUniqueId(),
|
||||
// deviceName: await DeviceInfo.getDeviceName(),
|
||||
// };
|
||||
// } catch (e) {
|
||||
// console.log('Xato:', e);
|
||||
// return null;
|
||||
// }
|
||||
// };
|
||||
|
||||
// useEffect(() => {
|
||||
// getDeviceData().then(data => {
|
||||
// setFirebseToken(data);
|
||||
// });
|
||||
// }, []);
|
||||
|
||||
useEffect(() => {
|
||||
getDeviceData().then(data => {
|
||||
setFirebseToken(data);
|
||||
});
|
||||
}, []);
|
||||
const { mutate, isPending } = useMutation({
|
||||
mutationFn: (payload: otpPayload) => authApi.verifyOtp(payload),
|
||||
onSuccess: async res => {
|
||||
@@ -149,16 +149,15 @@ const Confirm = ({
|
||||
|
||||
const handleVerifyCode = () => {
|
||||
const enteredCode = code.join('');
|
||||
if (firebaseToken) {
|
||||
|
||||
mutate({
|
||||
phoneNumber,
|
||||
otp: enteredCode,
|
||||
otpType: 'REGISTRATION',
|
||||
deviceId: firebaseToken.deviceId,
|
||||
deviceName: firebaseToken.deviceName,
|
||||
fcmToken: firebaseToken.fcmToken,
|
||||
deviceId: '',
|
||||
deviceName: '',
|
||||
fcmToken: '',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { getApp } from '@react-native-firebase/app';
|
||||
import { getMessaging, getToken } from '@react-native-firebase/messaging';
|
||||
// import { getApp } from '@react-native-firebase/app';
|
||||
// import { getMessaging, getToken } from '@react-native-firebase/messaging';
|
||||
import {
|
||||
type RouteProp,
|
||||
useNavigation,
|
||||
@@ -29,7 +29,6 @@ import {
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import DeviceInfo from 'react-native-device-info';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
import Logo from 'screens/../../assets/bootsplash/logo_512.png';
|
||||
import {
|
||||
@@ -67,36 +66,36 @@ const FirstStep = ({ onNext }: { onNext: () => void }) => {
|
||||
queryFn: branchApi.branchList,
|
||||
});
|
||||
|
||||
const [firebaseToken, setFirebseToken] = useState<{
|
||||
fcmToken: string;
|
||||
deviceId: string;
|
||||
deviceName: string;
|
||||
deviceType: string;
|
||||
} | null>();
|
||||
// const [firebaseToken, setFirebseToken] = useState<{
|
||||
// fcmToken: string;
|
||||
// deviceId: string;
|
||||
// deviceName: string;
|
||||
// deviceType: string;
|
||||
// } | null>();
|
||||
|
||||
const app = getApp();
|
||||
const messaging = getMessaging(app);
|
||||
// const app = getApp();
|
||||
// const messaging = getMessaging(app);
|
||||
|
||||
const getDeviceData = async () => {
|
||||
try {
|
||||
const fcmToken = await getToken(messaging);
|
||||
return {
|
||||
fcmToken,
|
||||
deviceId: await DeviceInfo.getUniqueId(),
|
||||
deviceName: await DeviceInfo.getDeviceName(),
|
||||
deviceType: await DeviceInfo.getDeviceType(),
|
||||
};
|
||||
} catch (e) {
|
||||
console.log('Xato:', e);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
// const getDeviceData = async () => {
|
||||
// try {
|
||||
// const fcmToken = await getToken(messaging);
|
||||
// return {
|
||||
// fcmToken,
|
||||
// deviceId: await DeviceInfo.getUniqueId(),
|
||||
// deviceName: await DeviceInfo.getDeviceName(),
|
||||
// deviceType: await DeviceInfo.getDeviceType(),
|
||||
// };
|
||||
// } catch (e) {
|
||||
// console.log('Xato:', e);
|
||||
// return null;
|
||||
// }
|
||||
// };
|
||||
|
||||
useEffect(() => {
|
||||
getDeviceData().then(data => {
|
||||
setFirebseToken(data);
|
||||
});
|
||||
}, []);
|
||||
// useEffect(() => {
|
||||
// getDeviceData().then(data => {
|
||||
// setFirebseToken(data);
|
||||
// });
|
||||
// }, []);
|
||||
|
||||
const { mutate, isPending } = useMutation({
|
||||
mutationFn: (payload: registerPayload) => authApi.register(payload),
|
||||
@@ -144,10 +143,10 @@ const FirstStep = ({ onNext }: { onNext: () => void }) => {
|
||||
recommend: data.recommend,
|
||||
branchId: data.branchId,
|
||||
address: data.address,
|
||||
fcmToken: firebaseToken?.fcmToken || '',
|
||||
deviceId: firebaseToken?.deviceId || '',
|
||||
deviceType: firebaseToken?.deviceType || '',
|
||||
deviceName: firebaseToken?.deviceId || '',
|
||||
fcmToken: '',
|
||||
deviceId: '',
|
||||
deviceType: '',
|
||||
deviceName: '',
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -7,14 +7,12 @@ import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Alert,
|
||||
Linking,
|
||||
Platform,
|
||||
StyleSheet,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import AppLink from 'react-native-app-link';
|
||||
import ArrowRightUnderline from 'svg/ArrowRightUnderline';
|
||||
import Bell from 'svg/Bell';
|
||||
import Location from 'svg/Location';
|
||||
import Logout from 'svg/LogOut';
|
||||
import Setting from 'svg/Setting';
|
||||
@@ -80,7 +78,7 @@ const ProfilePages = (props: componentNameProps) => {
|
||||
</View>
|
||||
<ArrowRightUnderline color="#373737" width={24} height={24} />
|
||||
</TouchableOpacity>
|
||||
{Platform.OS === 'android' && (
|
||||
{/* {Platform.OS === 'android' && (
|
||||
<TouchableOpacity
|
||||
style={[
|
||||
styles.card,
|
||||
@@ -94,7 +92,7 @@ const ProfilePages = (props: componentNameProps) => {
|
||||
</View>
|
||||
<ArrowRightUnderline color="#373737" width={24} height={24} />
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
)} */}
|
||||
<TouchableOpacity
|
||||
style={[
|
||||
styles.card,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { initializeApp } from '@react-native-firebase/app';
|
||||
import { getMessaging } from '@react-native-firebase/messaging';
|
||||
// import { initializeApp } from '@react-native-firebase/app';
|
||||
// import { getMessaging } from '@react-native-firebase/messaging';
|
||||
|
||||
const firebaseConfig = {
|
||||
apiKey: 'AIzaSyBEwWi1TuZBNj2hkFGGIaWZNNDCoiC__lE',
|
||||
authDomain: 'cpcargo-aee14.firebaseapp.com',
|
||||
projectId: 'cpcargo-aee14',
|
||||
storageBucket: 'cpcargo-aee14.firebasestorage.app',
|
||||
messagingSenderId: '1030089382290',
|
||||
appId: '1:1030089382290:android:668f0669ad4ac3f74dc94b',
|
||||
};
|
||||
// const firebaseConfig = {
|
||||
// apiKey: 'AIzaSyBEwWi1TuZBNj2hkFGGIaWZNNDCoiC__lE',
|
||||
// authDomain: 'cpcargo-aee14.firebaseapp.com',
|
||||
// projectId: 'cpcargo-aee14',
|
||||
// storageBucket: 'cpcargo-aee14.firebasestorage.app',
|
||||
// messagingSenderId: '1030089382290',
|
||||
// appId: '1:1030089382290:android:668f0669ad4ac3f74dc94b',
|
||||
// };
|
||||
|
||||
export const firebaseApp = initializeApp(firebaseConfig);
|
||||
export const messaging = getMessaging(await firebaseApp);
|
||||
// export const firebaseApp = initializeApp(firebaseConfig);
|
||||
// export const messaging = getMessaging(await firebaseApp);
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
// firebase.js
|
||||
import { initializeApp } from '@react-native-firebase/app';
|
||||
// import { initializeApp } from '@react-native-firebase/app';
|
||||
|
||||
const firebaseConfig = {
|
||||
apiKey: 'AIzaSyBnFzHK6XAjxzcQAsg0hFbeRcon8ZMDvVw', // api_key → current_key
|
||||
authDomain: 'cpcargo-77d93.firebaseapp.com', // Firebase web SDK uchun qo‘shimcha, yo‘q bo‘lsa qoldirish mumkin
|
||||
projectId: 'cpcargo-77d93', // project_info → project_id
|
||||
storageBucket: 'cpcargo-77d93.firebasestorage.app', // project_info → storage_bucket
|
||||
messagingSenderId: '628048576398', // project_info → project_number
|
||||
appId: '1:628048576398:android:f93293c00f463267a92edf', // client_info → mobilesdk_app_id
|
||||
};
|
||||
// const firebaseConfig = {
|
||||
// apiKey: 'AIzaSyBnFzHK6XAjxzcQAsg0hFbeRcon8ZMDvVw',
|
||||
// authDomain: 'cpcargo-77d93.firebaseapp.com',
|
||||
// projectId: 'cpcargo-77d93',
|
||||
// storageBucket: 'cpcargo-77d93.firebasestorage.app',
|
||||
// messagingSenderId: '628048576398',
|
||||
// appId: '1:628048576398:android:f93293c00f463267a92edf',
|
||||
// };
|
||||
|
||||
// Firebase ilovasini initialize qilish
|
||||
const app = initializeApp(firebaseConfig);
|
||||
// const app = initializeApp(firebaseConfig);
|
||||
|
||||
export default app;
|
||||
// export default app;
|
||||
|
||||
Reference in New Issue
Block a user