diff --git a/App.tsx b/App.tsx
index 1d4ae51..693dbd8 100644
--- a/App.tsx
+++ b/App.tsx
@@ -12,6 +12,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
import {QueryClient, QueryClientProvider} from 'react-query';
import {getRegisterStatus, postFcmToken, postToken} from './src/api';
import messaging from '@react-native-firebase/messaging';
+import {Alert, AppRegistry} from 'react-native';
async function requestUserPermission() {
const authStatus = await messaging().requestPermission();
@@ -35,23 +36,38 @@ export default function App() {
// 실행하면 가장 먼저 로컬에 로그인 정보 있는지 확인
useEffect(() => {
- getToken();
+ getTokens();
requestUserPermission();
messaging()
.getToken()
.then((token) => {
+ console.log('나의 소중한 기계의 토큰 ', token);
return postFcmToken(token);
});
+ messaging().setBackgroundMessageHandler(async (remoteMessage) => {
+ console.log('Message handled in the background!', remoteMessage);
+ });
+
+ AppRegistry.registerComponent('app', () => App);
+
const id = setTimeout(() => {
setLoading(false);
}, 2000);
return () => clearTimeout(id);
}, []);
- const getToken = async () => {
+ useEffect(() => {
+ const unsubscribe = messaging().onMessage(async (remoteMessage) => {
+ Alert.alert('A new FCM message arrived!', JSON.stringify(remoteMessage));
+ });
+
+ return unsubscribe;
+ }, []);
+
+ const getTokens = async () => {
try {
const value = await AsyncStorage.getItem('accessToken');
//여기서 아이디는 있지만 회원가입을 다 안한 상태라면 로그인 창 띄우고 했다면 메인으로 바로 가기.
diff --git a/ios/BOB_FrontEnd/Info.plist b/ios/BOB_FrontEnd/Info.plist
index b6d64f9..a22596b 100644
--- a/ios/BOB_FrontEnd/Info.plist
+++ b/ios/BOB_FrontEnd/Info.plist
@@ -56,7 +56,7 @@
NSCameraUsageDescription
$(PRODUCT_NAME) would like to use your camera
NSLocationWhenInUseUsageDescription
-
+
NSPhotoLibraryAddUsageDescription
$(PRODUCT_NAME) would like to save photos to your photo gallery
NSPhotoLibraryUsageDescription
diff --git a/ios/Podfile.lock b/ios/Podfile.lock
index a831737..35619c2 100644
--- a/ios/Podfile.lock
+++ b/ios/Podfile.lock
@@ -466,7 +466,7 @@ PODS:
- Firebase/Auth (= 8.15.0)
- React-Core
- RNFBApp
- - RNFBMessaging (15.1.1):
+ - RNFBMessaging (14.11.1):
- Firebase/Messaging (= 8.15.0)
- React-Core
- RNFBApp
@@ -801,7 +801,7 @@ SPEC CHECKSUMS:
RNFastImage: 1f2cab428712a4baaf78d6169eaec7f622556dd7
RNFBApp: 9646e09d041ea159b84584865212e4cf33acd179
RNFBAuth: af943e3ba071b5f4d18896c31e6cba3a77b1fa08
- RNFBMessaging: e67ce2a6aee26741b89dd61d08d578beb4e95e32
+ RNFBMessaging: 3e2682ea5e15fe86da24d16d16019395a881f33c
RNGestureHandler: 61628a2c859172551aa2100d3e73d1e57878392f
RNGoogleSignin: d7f8368b82d94f1dec964785d496387ca7f19092
RNReanimated: 64573e25e078ae6bec03b891586d50b9ec284393
diff --git a/package-lock.json b/package-lock.json
index 8a2202b..be7f92d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16,7 +16,7 @@
"@react-native-community/masked-view": "^0.1.11",
"@react-native-firebase/app": "^14.11.1",
"@react-native-firebase/auth": "^14.11.1",
- "@react-native-firebase/messaging": "^15.1.1",
+ "@react-native-firebase/messaging": "^14.11.1",
"@react-native-google-signin/google-signin": "^7.2.2",
"@react-navigation/bottom-tabs": "^6.3.1",
"@react-navigation/native": "^6.0.10",
@@ -4614,11 +4614,11 @@
}
},
"node_modules/@react-native-firebase/messaging": {
- "version": "15.1.1",
- "resolved": "https://registry.npmjs.org/@react-native-firebase/messaging/-/messaging-15.1.1.tgz",
- "integrity": "sha512-oWN4/919U44jJQDKVd5+OIviIZ6jTZkMOVVvCLwtMh9WXI0tCd/E+be8zOjH3jHi6M0Zkf0IOXOd0QuwyrmQZw==",
+ "version": "14.11.1",
+ "resolved": "https://registry.npmjs.org/@react-native-firebase/messaging/-/messaging-14.11.1.tgz",
+ "integrity": "sha512-nJjmA+Oku/rWM//y0hpsXJAM8dqkucZKyu71bZ8f4XCOU0ueqO/Qlyv8ylQ/2G+4+FCoSxncffxDdUfr+3nExA==",
"peerDependencies": {
- "@react-native-firebase/app": "15.1.1"
+ "@react-native-firebase/app": "14.11.1"
}
},
"node_modules/@react-native-google-signin/google-signin": {
@@ -20468,9 +20468,9 @@
"integrity": "sha512-IzgFakon2jkuC4FEP8q9wruz8Yu0yem/Yk0v8IwndV2h/5lYmmij/f5Pyk74U3tadGOr9UrBsGkrWZMceiAjHQ=="
},
"@react-native-firebase/messaging": {
- "version": "15.1.1",
- "resolved": "https://registry.npmjs.org/@react-native-firebase/messaging/-/messaging-15.1.1.tgz",
- "integrity": "sha512-oWN4/919U44jJQDKVd5+OIviIZ6jTZkMOVVvCLwtMh9WXI0tCd/E+be8zOjH3jHi6M0Zkf0IOXOd0QuwyrmQZw=="
+ "version": "14.11.1",
+ "resolved": "https://registry.npmjs.org/@react-native-firebase/messaging/-/messaging-14.11.1.tgz",
+ "integrity": "sha512-nJjmA+Oku/rWM//y0hpsXJAM8dqkucZKyu71bZ8f4XCOU0ueqO/Qlyv8ylQ/2G+4+FCoSxncffxDdUfr+3nExA=="
},
"@react-native-google-signin/google-signin": {
"version": "7.2.2",
diff --git a/package.json b/package.json
index f44e795..3aed25e 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
"@react-native-community/masked-view": "^0.1.11",
"@react-native-firebase/app": "^14.11.1",
"@react-native-firebase/auth": "^14.11.1",
- "@react-native-firebase/messaging": "^15.1.1",
+ "@react-native-firebase/messaging": "^14.11.1",
"@react-native-google-signin/google-signin": "^7.2.2",
"@react-navigation/bottom-tabs": "^6.3.1",
"@react-navigation/native": "^6.0.10",
diff --git a/src/api/login.ts b/src/api/login.ts
index 5e3fd3c..18d68f6 100644
--- a/src/api/login.ts
+++ b/src/api/login.ts
@@ -37,9 +37,10 @@ export const getRegisterStatus = async () => {
}
};
-export const postFcmToken = async (token: string) => {
+export const postFcmToken = async (token: any) => {
+ const data = {token: token};
try {
- const response = await customAxios().post('/api/v1/fcm/me', token);
+ const response = await customAxios().post('/api/v1/fcm/me', data);
return response.data;
} catch (error) {
console.log('파이어베이스 토큰 받기 실패', error);
diff --git a/yarn.lock b/yarn.lock
index c54a9df..51f70e2 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1834,10 +1834,10 @@
"resolved" "https://registry.npmjs.org/@react-native-firebase/auth/-/auth-14.11.1.tgz"
"version" "14.11.1"
-"@react-native-firebase/messaging@^15.1.1":
- "integrity" "sha512-oWN4/919U44jJQDKVd5+OIviIZ6jTZkMOVVvCLwtMh9WXI0tCd/E+be8zOjH3jHi6M0Zkf0IOXOd0QuwyrmQZw=="
- "resolved" "https://registry.npmjs.org/@react-native-firebase/messaging/-/messaging-15.1.1.tgz"
- "version" "15.1.1"
+"@react-native-firebase/messaging@^14.11.1":
+ "integrity" "sha512-nJjmA+Oku/rWM//y0hpsXJAM8dqkucZKyu71bZ8f4XCOU0ueqO/Qlyv8ylQ/2G+4+FCoSxncffxDdUfr+3nExA=="
+ "resolved" "https://registry.npmjs.org/@react-native-firebase/messaging/-/messaging-14.11.1.tgz"
+ "version" "14.11.1"
"@react-native-google-signin/google-signin@^7.2.2":
"integrity" "sha512-FqSJAEYz+SNeIOyokFX3e7nbBgK0js/Hye0YNY+cV0Qf1NxKw1vRt2MQB3kfuVWFCb+OSovgQCl6W8dhYvsblw=="