Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InvestCustomer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Giang Tran
InvestCustomer
Commits
16d4fdc9
Commit
16d4fdc9
authored
Apr 16, 2021
by
Giang Tran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
control notification
parent
85e40365
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
183 additions
and
271 deletions
+183
-271
AndroidManifest.xml
android/app/src/main/AndroidManifest.xml
+0
-0
RootView.js
src/RootView.js
+4
-39
Success.js
src/Screens/Action/Wallet/Tab/Success.js
+12
-0
Watting.js
src/Screens/Action/Wallet/Tab/Watting.js
+19
-2
FeedbackView.js
src/Screens/Feedback/FeedbackView.js
+2
-2
Customer.js
src/Screens/LegalDocument/Customer.js
+1
-1
GeneralInfor.js
src/Screens/Menu/Profile/Tab/GeneralInfor.js
+2
-2
AddMethod.js
src/Screens/MethodPay/AddMethod.js
+1
-1
Calendar.js
src/Screens/NewFeed/Calendar/Calendar.js
+3
-3
item.js
src/Screens/NewFeed/Calendar/item.js
+2
-2
MediaDetail.js
src/Screens/NewFeed/Media/MediaDetail.js
+2
-2
NotificaitonView.js
src/Screens/Notification/NotificaitonView.js
+1
-1
SnackBarAction.js
src/actions/SnackBarAction.js
+3
-6
Drawer.js
src/components/Header/Drawer.js
+1
-1
HeaderBack.js
src/components/Header/HeaderBack.js
+2
-0
HeaderDrawer.js
src/components/Header/HeaderDrawer.js
+3
-1
HeaderHome.js
src/components/Header/HeaderHome.js
+2
-1
HeaderSB.js
src/components/Header/HeaderSB.js
+2
-1
SnackBar.js
src/components/SnackBar.js
+80
-68
FirebaseNotification.js
src/helper/FirebaseNotification.js
+40
-138
StackNavigation.js
src/routers/StackNavigation.js
+1
-0
No files found.
android/app/src/main/AndroidManifest.xml
View file @
16d4fdc9
src/RootView.js
View file @
16d4fdc9
...
...
@@ -5,51 +5,16 @@ import {connect} from 'react-redux';
import
StackNavigation
from
'./routers/StackNavigation'
;
import
Modal
from
'react-native-modal'
;
import
{
SkypeIndicator
}
from
'react-native-indicators'
;
import
{
HEIGHT
,
HEIGHTXD
}
from
'./Config/Functions'
;
import
R
from
'./assets/R'
;
import
messaging
from
'@react-native-firebase/messaging'
;
import
FirebaseNotification
from
'./helper/FirebaseNotification'
;
import
{
enableScreens
}
from
'react-native-screens'
;
import
AsyncStorage
from
'@react-native-community/async-storage'
;
import
KEY
from
'./assets/AsynStorage'
;
enableScreens
();
const
RootView
=
(
props
)
=>
{
messaging
().
setBackgroundMessageHandler
(
async
(
remoteMessage
)
=>
{
console
.
log
(
'Message handled in the background!'
,
remoteMessage
);
});
useEffect
(()
=>
{
requestUserPermission
();
const
unsubscribe
=
messaging
().
onMessage
(
async
(
remoteMessage
)
=>
{
console
.
log
(
'A new FCM message arrived!'
,
remoteMessage
);
});
return
unsubscribe
;
},
[]);
const
requestUserPermission
=
async
()
=>
{
const
authStatus
=
await
messaging
().
requestPermission
();
const
enabled
=
authStatus
===
messaging
.
AuthorizationStatus
.
AUTHORIZED
||
authStatus
===
messaging
.
AuthorizationStatus
.
PROVISIONAL
;
if
(
enabled
)
{
getFcmToken
();
console
.
log
(
'Authorization status:'
,
authStatus
);
}
};
const
getFcmToken
=
async
()
=>
{
let
fcmToken
=
await
AsyncStorage
.
getItem
(
KEY
.
FIREBASE
);
console
.
log
(
'Dat tao'
,
fcmToken
);
if
(
!
fcmToken
)
{
fcmToken
=
await
messaging
().
getToken
();
console
.
log
(
'Vua tao'
,
fcmToken
);
if
(
fcmToken
)
{
AsyncStorage
.
setItem
(
KEY
.
FIREBASE
,
fcmToken
);
}
}
};
return
(
<
View
style
=
{{
flex
:
1
}}
>
<
FirebaseNotification
/>
<
Modal
isVisible
=
{
props
.
loadingModal
.
isVisible
}
>
<
SkypeIndicator
color
=
{
'white'
}
/
>
<
/Modal
>
...
...
src/Screens/Action/Wallet/Tab/Success.js
View file @
16d4fdc9
...
...
@@ -67,6 +67,17 @@ const Success = (props) => {
return
(
<
View
style
=
{{
flex
:
1
}}
>
{
data
.
length
==
0
?
(
<
View
style
=
{{
justifyContent
:
'center'
,
alignItems
:
'center'
,
flex
:
1
}}
>
<
Text
style
=
{{
fontSize
:
18
,
fontWeight
:
'bold'
,
}}
>
Kh
ô
ng
c
ó
th
ô
ng
b
á
o
n
à
o
!
<
/Text
>
<
/View
>
)
:
(
<
FlatList
keyExtractor
=
{(
item
)
=>
item
.
transection_id
+
'a'
}
refreshing
=
{
isRefresh
}
...
...
@@ -78,6 +89,7 @@ const Success = (props) => {
data
=
{
data
}
renderItem
=
{({
item
})
=>
<
Item
item
=
{
item
}
/>
}
/>
)}
<
/View
>
);
};
...
...
src/Screens/Action/Wallet/Tab/Watting.js
View file @
16d4fdc9
...
...
@@ -3,16 +3,21 @@ import {View, Text, FlatList} from 'react-native';
import
HeaderBack
from
'../../../../components/Header/HeaderBack'
;
import
Item
from
'./Item'
;
import
{
getListTransaction
}
from
'../../../../apis/Functions/Widthdraw'
;
import
{
useNavigation
}
from
'@react-navigation/native'
;
const
Watting
=
(
props
)
=>
{
const
[
page
,
setPage
]
=
useState
(
1
);
const
[
data
,
setData
]
=
useState
([]);
const
[
tottalPage
,
setTotalPage
]
=
useState
(
1
);
const
[
isRefresh
,
setisRefresh
]
=
useState
(
false
);
const
navigation
=
useNavigation
();
useEffect
(()
=>
{
const
unsubscribe
=
navigation
.
addListener
(
'focus'
,
()
=>
{
getData
();
},
[]);
});
return
unsubscribe
;
},
[
navigation
]);
const
getData
=
async
()
=>
{
setisRefresh
(
true
);
...
...
@@ -67,6 +72,17 @@ const Watting = (props) => {
return
(
<
View
style
=
{{
flex
:
1
}}
>
{
data
.
length
==
0
?
(
<
View
style
=
{{
justifyContent
:
'center'
,
alignItems
:
'center'
,
flex
:
1
}}
>
<
Text
style
=
{{
fontSize
:
18
,
fontWeight
:
'bold'
,
}}
>
Kh
ô
ng
c
ó
th
ô
ng
b
á
o
n
à
o
!
<
/Text
>
<
/View
>
)
:
(
<
FlatList
keyExtractor
=
{(
item
)
=>
item
.
transection_id
+
'a'
}
refreshing
=
{
isRefresh
}
...
...
@@ -78,6 +94,7 @@ const Watting = (props) => {
data
=
{
data
}
renderItem
=
{({
item
})
=>
<
Item
item
=
{
item
}
/>
}
/>
)}
<
/View
>
);
};
...
...
src/Screens/Feedback/FeedbackView.js
View file @
16d4fdc9
...
...
@@ -62,7 +62,7 @@ const FeedbackView = (props) => {
keyboardVerticalOffset
=
{
-
50
}
>
<
TouchableWithoutFeedback
onPress
=
{
Keyboard
.
dismiss
}
>
<
View
style
=
{{
flex
:
1
}}
>
<
HeaderBack
isWhite
=
{
true
}
title
=
{
'G
ỬI FEEDBACK
'
}
/
>
<
HeaderBack
isWhite
=
{
true
}
title
=
{
'G
ửi phản hồi
'
}
/
>
<
View
style
=
{
styles
.
container
}
>
<
Text
style
=
{
styles
.
txt
}
>
Đá
nh
gi
á
d
ị
ch
v
ụ
c
ủ
a
DCV
Invest
<
/Text
>
...
...
@@ -149,7 +149,7 @@ const FeedbackView = (props) => {
<
View
style
=
{
styles
.
containerBtn
}
>
<
Button
onClick
=
{()
=>
console
.
log
(
'hello'
)}
title
=
{
'Gửi
feedback
'
}
title
=
{
'Gửi
phản hồi
'
}
/
>
<
/View
>
<
/View
>
...
...
src/Screens/LegalDocument/Customer.js
View file @
16d4fdc9
...
...
@@ -9,7 +9,7 @@ const Customer = (props) => {
const
navigate
=
useNavigation
();
return
(
<
View
style
=
{{
flex
:
1
}}
>
<
HeaderBack
title
=
{
'K
inh doanh chu
ng'
}
/
>
<
HeaderBack
title
=
{
'K
hách hà
ng'
}
/
>
<
View
style
=
{
styles
.
container
}
>
<
Text
style
=
{{
...
...
src/Screens/Menu/Profile/Tab/GeneralInfor.js
View file @
16d4fdc9
...
...
@@ -113,11 +113,11 @@ const GeneralInfor = (props) => {
<
View
style
=
{{
height
:
40
}}
/
>
<
View
style
=
{{
justifyContent
:
'center'
,
alignItems
:
'center'
}}
>
{
/*
<TouchableOpacity
<
TouchableOpacity
onPress
=
{()
=>
console
.
log
(
'Hello'
)}
style
=
{
styles
.
btn
}
>
<
Text
style
=
{
styles
.
txtBtn
}
>
C
ậ
p
nh
ậ
t
<
/Text
>
</TouchableOpacity> */
}
<
/TouchableOpacity
>
<
/View
>
<
/View
>
<
/ScrollView
>
...
...
src/Screens/MethodPay/AddMethod.js
View file @
16d4fdc9
...
...
@@ -70,7 +70,7 @@ const AddMethodPay = (props) => {
platform
:
Platform
.
OS
,
bank_id
:
bank_id
.
id
,
branch_name
,
account_name
,
account_name
:
account_name
.
toUpperCase
()
,
account_no
,
});
props
.
hideLoading
();
...
...
src/Screens/NewFeed/Calendar/Calendar.js
View file @
16d4fdc9
...
...
@@ -37,16 +37,16 @@ const NewFeed = (props) => {
const
scrollToCurrent
=
()
=>
{
const
date
=
new
Date
();
let
index
=
0
;
const
today
=
convertTimeApi
(
date
);
if
(
data
.
length
>
0
)
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
data
[
i
].
start_date
.
substring
(
0
,
10
)
==
today
)
{
index
=
i
;
break
;
}
else
{
index
=
30
-
today
.
substring
(
8
);
}
}
setTimeout
(()
=>
{
ListDayRef
.
current
.
scrollToIndex
({
animated
:
true
,
...
...
@@ -58,7 +58,7 @@ const NewFeed = (props) => {
const
getItemLayout
=
(
data
,
index
)
=>
({
length
:
100
,
offset
:
7
0
*
index
,
offset
:
6
0
*
index
,
index
,
});
...
...
src/Screens/NewFeed/Calendar/item.js
View file @
16d4fdc9
...
...
@@ -35,7 +35,7 @@ const styles = StyleSheet.create({
},
right
:
{
marginLeft
:
20
,
paddingVertical
:
2
0
,
paddingVertical
:
1
0
,
borderTopWidth
:
0.6
,
borderBottomWidth
:
0.6
,
borderColor
:
'#CECECE'
,
...
...
@@ -52,7 +52,7 @@ const styles = StyleSheet.create({
backgroundColor
:
R
.
colors
.
main
,
borderRadius
:
5
,
marginLeft
:
-
5
,
marginTop
:
2
5
,
marginTop
:
1
5
,
},
txtTitle
:
{
fontSize
:
getFontXD
(
42
),
...
...
src/Screens/NewFeed/Media/MediaDetail.js
View file @
16d4fdc9
...
...
@@ -38,11 +38,11 @@ const Item = (props) => {
<
/ImageBackground
>
<
View
style
=
{
styles
.
wrapRight
}
>
<
View
style
=
{{
flex
:
1
}}
>
<
Text
style
=
{
styles
.
txtTitle
}
numberOfLines
=
{
2
}
>
<
Text
style
=
{
styles
.
txtTitle
}
numberOfLines
=
{
4
}
>
{
title
}
<
/Text
>
<
/View
>
<
Text
>
{
published_at
}
<
/Text
>
<
Text
style
=
{{
color
:
'#8E8C8C'
}}
>
{
published_at
}
<
/Text
>
<
/View
>
<
/TouchableOpacity
>
);
...
...
src/Screens/Notification/NotificaitonView.js
View file @
16d4fdc9
...
...
@@ -68,7 +68,7 @@ const NotificaitonView = (props) => {
<
View
style
=
{{
justifyContent
:
'center'
,
alignItems
:
'center'
,
flex
:
1
}}
>
<
Text
style
=
{{
fontSize
:
getFontXD
(
46
)
,
fontSize
:
18
,
fontWeight
:
'bold'
,
}}
>
Kh
ô
ng
c
ó
th
ô
ng
b
á
o
n
à
o
!
...
...
src/actions/SnackBarAction.js
View file @
16d4fdc9
import
{
PUSHNOTI
,
HIDENOTI
}
from
'./actionTypes'
;
import
{
PUSHNOTI
,
HIDENOTI
}
from
'./actionTypes'
;
export
const
showNotificaton
=
(
data
)
=>
{
return
{
type
:
PUSHNOTI
,
data
data
,
};
};
export
const
hideNotification
=
()
=>
{
return
{
type
:
HIDENOTI
type
:
HIDENOTI
,
};
};
src/components/Header/Drawer.js
View file @
16d4fdc9
...
...
@@ -77,7 +77,7 @@ const Drawer = (props) => {
navigate
.
navigate
(
PROFILE
);
}}
>
<
Text
style
=
{
styles
.
txtTop
}
>
{
props
.
user
.
fullname
}
<
/Text
>
<
Text
>
{
props
.
user
.
sponso
r_id
}
<
/Text
>
<
Text
>
{
props
.
user
.
use
r_id
}
<
/Text
>
<
/TouchableOpacity
>
<
TouchableOpacity
onPress
=
{()
=>
{
...
...
src/components/Header/HeaderBack.js
View file @
16d4fdc9
...
...
@@ -18,6 +18,7 @@ import LinearGradient from 'react-native-linear-gradient';
import
{
connect
}
from
'react-redux'
;
import
{
HEIGHTXD
}
from
'../../Config/Functions'
;
import
{
useNavigation
}
from
'@react-navigation/native'
;
import
SnackBar
from
'../SnackBar'
;
const
HeaderHome
=
(
props
)
=>
{
const
{
title
,
isWhite
}
=
props
;
const
navigate
=
useNavigation
();
...
...
@@ -26,6 +27,7 @@ const HeaderHome = (props) => {
imageStyle
=
{{
resizeMode
:
'stretch'
}}
style
=
{[
styles
.
img
,
isWhite
?
{
backgroundColor
:
'white'
}
:
{}]}
source
=
{
R
.
images
.
bgHeader
}
>
<
SnackBar
/>
<
StatusBar
backgroundColor
=
"transparent"
translucent
=
{
true
}
/
>
<
View
style
=
{
styles
.
headerContainer
}
>
<
TouchableOpacity
onPress
=
{()
=>
navigate
.
goBack
()}
>
...
...
src/components/Header/HeaderDrawer.js
View file @
16d4fdc9
...
...
@@ -19,7 +19,7 @@ import {connect} from 'react-redux';
import
{
HEIGHTXD
}
from
'../../Config/Functions'
;
import
Modal
from
'react-native-modal'
;
import
Drawer
from
'./Drawer'
;
import
SnackBar
from
'../SnackBar'
;
const
HeaderDrawer
=
(
props
)
=>
{
const
{
title
,
isWhite
}
=
props
;
const
[
isModalVisible
,
setModalVisible
]
=
useState
(
false
);
...
...
@@ -33,7 +33,9 @@ const HeaderDrawer = (props) => {
imageStyle
=
{{
resizeMode
:
'stretch'
}}
style
=
{[
styles
.
img
,
isWhite
?
{
backgroundColor
:
'white'
}
:
{}]}
source
=
{
R
.
images
.
bgHeader
}
>
<
SnackBar
/>
<
StatusBar
backgroundColor
=
"transparent"
translucent
=
{
true
}
/
>
<
View
style
=
{
styles
.
headerContainer
}
>
<
TouchableOpacity
onPress
=
{
toggleModal
}
>
<
Image
source
=
{
R
.
images
.
iconMenu
}
style
=
{
styles
.
imgIcon
}
/
>
...
...
src/components/Header/HeaderHome.js
View file @
16d4fdc9
...
...
@@ -17,7 +17,7 @@ import LinearGradient from 'react-native-linear-gradient';
import
{
connect
}
from
'react-redux'
;
import
{
HEIGHTXD
,
toPriceVnd
}
from
'../../Config/Functions'
;
import
Clipboard
from
'@react-native-clipboard/clipboard'
;
import
SnackBar
from
'../SnackBar'
;
import
{
useNavigation
}
from
'@react-navigation/native'
;
import
{
WITHDRAW
,
...
...
@@ -117,6 +117,7 @@ const HeaderHome = (props) => {
return
(
<
View
style
=
{
styles
.
container
}
>
<
SnackBar
/>
<
StatusBar
backgroundColor
=
"transparent"
translucent
=
{
true
}
/
>
<
View
style
=
{{
...
...
src/components/Header/HeaderSB.js
View file @
16d4fdc9
...
...
@@ -18,7 +18,7 @@ import {getFontXD, HEIGHT, WIDTHXD} from '../../Config/Functions';
import
LinearGradient
from
'react-native-linear-gradient'
;
import
{
connect
}
from
'react-redux'
;
import
{
HEIGHTXD
}
from
'../../Config/Functions'
;
import
SnackBar
from
'../SnackBar'
;
import
Icon
from
'react-native-vector-icons/Ionicons'
;
import
{
useNavigation
}
from
'@react-navigation/native'
;
...
...
@@ -39,6 +39,7 @@ const HeaderSearch = (props) => {
style
=
{[
styles
.
img
,
isWhite
?
{
backgroundColor
:
'white'
}
:
{}]}
source
=
{
R
.
images
.
bgHeader
}
>
<
StatusBar
backgroundColor
=
"transparent"
translucent
=
{
true
}
/
>
<
SnackBar
/>
<
View
style
=
{
styles
.
headerContainer
}
>
<
TouchableOpacity
onPress
=
{()
=>
navigate
.
goBack
()}
>
<
Image
source
=
{
R
.
images
.
iconBack
}
style
=
{
styles
.
imgIcon
}
/
>
...
...
src/components/SnackBar.js
View file @
16d4fdc9
import
React
,{
useState
,
useEffect
}
from
'react'
;
import
{
View
,
Text
,
StyleSheet
,
TouchableOpacity
,
StatusBar
,
TouchableWithoutFeedback
}
from
'react-native'
;
import
R
from
'../assets/R'
import
Block
from
'./Block'
import
{
getFontXD
,
HEIGHTXD
}
from
"../config/Functions"
;
import
LinearGradient
from
"react-native-linear-gradient"
;
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
{
View
,
Text
,
StyleSheet
,
TouchableOpacity
,
StatusBar
,
TouchableWithoutFeedback
,
}
from
'react-native'
;
import
R
from
'../assets/R'
;
import
Block
from
'./Block'
;
import
{
getFontXD
,
HEIGHTXD
}
from
'../Config/Functions'
;
import
LinearGradient
from
'react-native-linear-gradient'
;
import
Modal
from
'react-native-modal'
;
import
SnackReducer
from
"../reducers/SnackReducer"
;
import
{
connect
}
from
'react-redux'
import
{
showNotificaton
,
hideNotification
}
from
'../actions/SnackBarAction'
import
{
connect
}
from
'react-redux'
;
import
{
showNotificaton
,
hideNotification
}
from
'../actions/SnackBarAction'
;
import
{
useNavigation
}
from
'@react-navigation/native'
;
const
SnackBar
=
(
props
)
=>
{
const
SnackBar
=
(
props
)
=>
{
const
navigate
=
useNavigation
();
const
{
isOpen
,
title
,
content
,
screen
,
id_record
}
=
props
.
snackReducer
;
useEffect
(()
=>
{
console
.
log
(
'Reducer'
,
props
.
snackReducer
);
if
(
isOpen
)
setTimeout
(()
=>
{
props
.
hideNotification
();
},
10000
);
},
[
props
.
snackReducer
]);
const
navigation
=
useNavigation
();
const
{
isOpen
,
title
,
content
,
screen
,
id_record
}
=
props
.
snackReducer
useEffect
(()
=>
{
if
(
isOpen
)
setTimeout
(()
=>
{
props
.
hideNotification
()
},
10000
)
},[
props
.
snackReducer
])
return
(
<
Modal
style
=
{{
padding
:
0
,
margin
:
0
}}
animationInTiming
=
{
1500
}
animationOutTiming
=
{
800
}
backdropOpacity
=
{
0
}
animationIn
=
{
'slideInDown'
}
animationOut
=
{
'slideOutUp'
}
isVisible
=
{
isOpen
}
>
<
View
style
=
{
styles
.
container
}
>
<
View
style
=
{{
flex
:
1
}}
>
return
(
<
Modal
style
=
{{
padding
:
0
,
margin
:
0
}}
animationInTiming
=
{
1500
}
animationOutTiming
=
{
800
}
backdropOpacity
=
{
0
}
animationIn
=
{
'slideInDown'
}
animationOut
=
{
'slideOutUp'
}
isVisible
=
{
isOpen
}
>
<
View
style
=
{
styles
.
container
}
>
<
View
style
=
{{
flex
:
1
}}
>
<
Text
style
=
{
styles
.
txtTitle
}
>
{
title
}
<
/Text
>
<
Text
numberOfLines
=
{
2
}
style
=
{
styles
.
txt
}
>
{
content
}
<
/Text
>
<
Text
numberOfLines
=
{
2
}
style
=
{
styles
.
txt
}
>
{
content
}
<
/Text
>
<
/View
>
<
View
style
=
{
styles
.
row
}
>
<
TouchableOpacity
onPress
=
{
()
=>
props
.
hideNotification
()}
style
=
{
styles
.
btn
}
>
<
TouchableOpacity
onPress
=
{()
=>
props
.
hideNotification
()}
style
=
{
styles
.
btn
}
>
<
Text
style
=
{
styles
.
txtBtn
}
>
Đó
ng
<
/Text
>
<
/TouchableOpacity
>
<
TouchableOpacity
onPress
=
{()
=>
{
props
.
hideNotification
()
navigation
.
navigate
(
screen
,{
id
:
id_record
})
}
}
style
=
{[
styles
.
btn
,{
marginLeft
:
20
}]}
>
<
Text
style
=
{
styles
.
txtBtn
}
>
Chi
ti
ế
t
<
/Text
>
<
TouchableOpacity
onPress
=
{()
=>
{
props
.
hideNotification
();
navigate
.
navigate
(
screen
,
{
id
:
id_record
});
}}
style
=
{[
styles
.
btn
,
{
marginLeft
:
20
}]}
>
<
Text
style
=
{
styles
.
txtBtn
}
>
Chi
ti
ế
t
<
/Text
>
<
/TouchableOpacity
>
<
/View
>
<
/View
>
<
TouchableWithoutFeedback
onPress
=
{
()
=>
props
.
hideNotification
()}
>
<
View
style
=
{{
flex
:
1
}}
>
<
/View
>
<
TouchableWithoutFeedback
onPress
=
{()
=>
props
.
hideNotification
()}
>
<
View
style
=
{{
flex
:
1
}}
><
/View
>
<
/TouchableWithoutFeedback
>
<
/Modal
>
);
};
)
}
const
mapStateToProps
=
(
state
)
=>
{
const
mapStateToProps
=
(
state
)
=>
{
return
{
snackReducer
:
state
.
SnackReducer
,
};
};
export
default
connect
(
mapStateToProps
,
{
showNotificaton
,
hideNotification
})(
SnackBar
);
export
default
connect
(
mapStateToProps
,
{
showNotificaton
,
hideNotification
})(
SnackBar
,
);
const
styles
=
StyleSheet
.
create
({
container
:{
marginTop
:
10
,
height
:
HEIGHTXD
(
380
),
backgroundColor
:
R
.
colors
.
white
,
marginHorizontal
:
10
,
borderRadius
:
10
,
paddingVertical
:
10
,
paddingHorizontal
:
10
,
const
styles
=
StyleSheet
.
create
({
container
:
{
marginTop
:
10
,
height
:
HEIGHTXD
(
380
),
backgroundColor
:
R
.
colors
.
white
,
marginHorizontal
:
10
,
borderRadius
:
10
,
paddingVertical
:
10
,
paddingHorizontal
:
10
,
shadowColor
:
'#000'
,
shadowOffset
:
{
width
:
0
,
...
...
@@ -83,21 +95,21 @@ const styles=StyleSheet.create({
shadowRadius
:
3.84
,
elevation
:
3
,
},
row
:{
flexDirection
:
'row'
,
justifyContent
:
'flex-end'
,
row
:
{
flexDirection
:
'row'
,
justifyContent
:
'flex-end'
,
},
txt
:{
color
:
R
.
colors
.
black
txt
:
{
color
:
R
.
colors
.
black
,
},
txtBtn
:{
fontSize
:
getFontXD
(
42
),
color
:
R
.
colors
.
txtMain
,
fontWeight
:
'bold'
txtBtn
:
{
fontSize
:
getFontXD
(
42
),
color
:
R
.
colors
.
txtMain
,
fontWeight
:
'bold'
,
},
txtTitle
:{
fontSize
:
getFontXD
(
42
),
txtTitle
:
{
fontSize
:
getFontXD
(
42
),
color
:
R
.
colors
.
black
,
fontWeight
:
'bold'
}
})
fontWeight
:
'bold'
,
}
,
})
;
src/helper/FirebaseNotification.js
View file @
16d4fdc9
/* eslint-disable no-console */
import
React
from
'react'
;
import
React
,
{
useEffect
}
from
'react'
;
import
{
Platform
,
View
,
Alert
}
from
'react-native'
;
import
firebase
from
'@react-native-firebase/app'
;
import
sampleaudio
from
'../../sampleaudio.mp3'
;
import
messaging
from
'@react-native-firebase/messaging'
;
import
AsyncStorage
from
'@react-native-community/async-storage'
;
import
KEY
from
'../assets/AsynStorage'
;
import
{
showNotificaton
,
updateNotification
}
from
'../actions/SnackBarAction'
;
import
{
connect
}
from
'react-redux'
;
const
FirebaseNotification
=
(
props
)
=>
{
messaging
().
setBackgroundMessageHandler
(
async
(
remoteMessage
)
=>
{
console
.
log
(
'Message handled in the background!'
,
remoteMessage
);
});
useEffect
(()
=>
{
requestUserPermission
();
const
unsubscribe
=
messaging
().
onMessage
(
async
(
remoteMessage
)
=>
{
console
.
log
(
'A new FCM message arrived!'
,
remoteMessage
);
props
.
showNotificaton
({
title
:
'Title'
,
content
:
'Content notification'
,
screen
:
'NOTIFICATION'
,
id_record
:
9
,
});
});
return
unsubscribe
;
},
[]);
const
requestUserPermission
=
async
()
=>
{
const
authStatus
=
await
messaging
().
requestPermission
();
const
enabled
=
authStatus
===
messaging
.
AuthorizationStatus
.
AUTHORIZED
||
authStatus
===
messaging
.
AuthorizationStatus
.
PROVISIONAL
;
class
FirebaseNotification
extends
React
.
PureComponent
{
checkPermission
=
()
=>
{
firebase
.
messaging
()
.
hasPermission
()
.
then
((
enabled
)
=>
{
if
(
enabled
)
{
this
.
getToken
();
}
else
{
this
.
requestPermission
();
getFcmToken
();
}
});
};
requestPermission
=
async
()
=>
{
try
{
await
firebase
.
messaging
().
requestPermission
();
this
.
getToken
();
}
catch
(
error
)
{}
};
getToken
=
async
()
=>
{
const
getFcmToken
=
async
()
=>
{
let
fcmToken
=
await
AsyncStorage
.
getItem
(
KEY
.
FIREBASE
);
console
.
log
(
'Dat tao'
,
fcmToken
);
if
(
!
fcmToken
)
{
fcmToken
=
await
firebase
.
messaging
().
getToken
();
console
.
log
(
'Vua tao'
,
fcmToken
);
fcmToken
=
await
messaging
().
getToken
();
if
(
fcmToken
)
{
AsyncStorage
.
setItem
(
KEY
.
FIREBASE
,
fcmToken
);
}
}
};
async
componentDidMount
()
{
this
.
checkPermission
();
this
.
createNotificationListeners
();
this
.
removeNotificationDisplayedListener
=
firebase
.
notifications
()
.
onNotificationDisplayed
((
notification
)
=>
{
console
.
log
(
'Can alert'
,
notification
);
this
.
props
.
onReceived
(
notification
);
// Process your notification as required
// ANDROID: Remote notifications do not contain the channel ID. You will have to specify this manually if you'd like to re-display the notification.
});
}
componentWillUnmount
()
{
this
.
removeNotificationDisplayedListener
;
this
.
notificationListener
;
this
.
notificationOpenedListener
;
}
async
createNotificationListeners
()
{
/*
* Triggered when a particular notification has been received in foreground
* */
console
.
log
(
'Notification log'
);
const
channel
=
new
firebase
.
notifications
.
Android
.
Channel
(
'500'
,
'Channel Name 1001'
,
firebase
.
notifications
.
Android
.
Importance
.
Max
,
)
.
setDescription
(
'A natural description of the channel'
)
.
setSound
(
'default'
);
firebase
.
notifications
().
android
.
createChannel
(
channel
);
this
.
notificationListener
=
firebase
.
notifications
()
.
onNotification
((
notification
)
=>
{
console
.
log
(
'notificaiton'
,
notification
);
if
(
Platform
.
OS
===
'android'
)
{
const
localNotification
=
new
firebase
.
notifications
.
Notification
({
sound
:
sampleaudio
,
show_in_foreground
:
true
,
})
.
setSound
(
'default'
)
.
setNotificationId
(
notification
.
notificationId
)
.
setTitle
(
notification
.
title
)
.
setBody
(
notification
.
body
)
.
setData
(
notification
.
data
)
.
android
.
setChannelId
(
'default_notification_channel_id'
)
// e.g. the id you chose above
// .android.setSmallIcon('@mipmap/ic_launcher') // create this icon in Android Studio
// .android.setColor('red') // you can set a color here
.
android
.
setPriority
(
firebase
.
notifications
.
Android
.
Priority
.
High
)
.
android
.
setVibrate
([
300
])
.
android
.
setDefaults
([
firebase
.
notifications
.
Android
.
Defaults
.
Vibrate
,
]);
console
.
log
(
'Notification:'
,
localNotification
);
firebase
.
notifications
()
.
displayNotification
(
localNotification
)
.
catch
((
err
)
=>
console
.
error
(
'Chay vao day android'
,
err
));
}
else
if
(
Platform
.
OS
===
'ios'
)
{
const
localNotification
=
new
firebase
.
notifications
.
Notification
()
.
setNotificationId
(
notification
.
notificationId
)
.
setTitle
(
notification
.
title
)
.
setSubtitle
(
notification
.
subtitle
)
.
setBody
(
notification
.
body
)
.
setData
(
notification
.
data
)
.
ios
.
setBadge
(
notification
.
ios
.
badge
)
.
ios
.
setLaunchImage
(
'@mipmap/ic_stat_ic_notification'
);
firebase
.
notifications
()
.
displayNotification
(
localNotification
)
.
catch
((
err
)
=>
console
.
error
(
'Chay vao day'
,
err
));
}
// this.getNotifyNumber();
});
/*
* If your app is in background, you can listen for when a notification is clicked / tapped / opened as follows:
* */
this
.
notificationOpenedListener
=
firebase
.
notifications
()
.
onNotificationOpened
((
notificationOpen
)
=>
{
this
.
props
.
onOpened
(
notificationOpen
.
notification
);
});
/*
* If your app is closed, you can check if it was opened by a notification being clicked / tapped / opened as follows:
* */
const
notificationOpen
=
await
firebase
.
notifications
()
.
getInitialNotification
();
if
(
notificationOpen
)
{
this
.
props
.
onOpened
(
notificationOpen
.
notification
);
}
/*
* Triggered for data only payload in foreground
* */
this
.
messageListener
=
firebase
.
messaging
().
onMessage
((
message
)
=>
{
// process data message
console
.
log
(
'message---'
,
message
);
this
.
props
.
onReceived
(
message
);
});
}
render
()
{
return
<
View
/>
;
}
}
};
const
mapStateToProps
=
(
state
)
=>
{
return
{
loadingModal
:
state
.
ModalLoadingReducer
,
};
};
export
default
FirebaseNotification
;
export
default
connect
(
mapStateToProps
,
{
showNotificaton
,
updateNotification
})(
FirebaseNotification
,
);
src/routers/StackNavigation.js
View file @
16d4fdc9
...
...
@@ -43,6 +43,7 @@ import LegaDocument from '../Screens/LegalDocument/LegalDocument';
import
Business
from
'../Screens/LegalDocument/Business'
;
import
Customer
from
'../Screens/LegalDocument/Customer'
;
import
Partner
from
'../Screens/LegalDocument/Partner'
;
import
SnackBar
from
'../components/SnackBar'
;
import
*
as
ScreenName
from
'./ScreenNames'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment