File tree 5 files changed +18
-9
lines changed 5 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ const App = () => {
24
24
pricingPlan : 'paid' ,
25
25
status : 'active' ,
26
26
} ;
27
- const websiteToken = 'uDDidz9scvbDBcxjCfwdWJRZ ' ;
28
- const baseUrl = 'https://mobile .chatwoot.app ' ;
27
+ const websiteToken = 'RY3LaFtwmkPhDdZVmRd4ektW ' ;
28
+ const baseUrl = 'https://staging .chatwoot.com ' ;
29
29
const [ locale , setLocale ] = useState ( 'en' ) ;
30
30
31
31
return (
@@ -81,7 +81,7 @@ const App = () => {
81
81
websiteToken = { websiteToken }
82
82
locale = { locale }
83
83
baseUrl = { baseUrl }
84
- colorScheme = "dark "
84
+ colorScheme = "light "
85
85
closeModal = { ( ) => toggleWidget ( false ) }
86
86
isModalVisible = { showWidget }
87
87
user = { user }
Original file line number Diff line number Diff line change 11
11
"test" : " jest"
12
12
},
13
13
"dependencies" : {
14
- "@chatwoot/react-native-widget" : " ../chatwoot-react-native-widget-0.0.14 .tgz" ,
14
+ "@chatwoot/react-native-widget" : " ../chatwoot-react-native-widget-0.0.16 .tgz" ,
15
15
"@react-native-async-storage/async-storage" : " ^1.18.1" ,
16
16
"react" : " 18.2.0" ,
17
17
"react-native" : " 0.71.8" ,
Original file line number Diff line number Diff line change 1062
1062
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
1063
1063
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
1064
1064
1065
- " @chatwoot/react-native-widget@../chatwoot-react-native-widget-0.0.14 .tgz " :
1066
- version "0.0.14 "
1067
- resolved "../chatwoot-react-native-widget-0.0.14 .tgz#66fa6465ca0c9027023c7ca9562ab27ad1835cb6 "
1065
+ " @chatwoot/react-native-widget@../chatwoot-react-native-widget-0.0.16 .tgz " :
1066
+ version "0.0.16 "
1067
+ resolved "../chatwoot-react-native-widget-0.0.16 .tgz#92fc5b787751147d4ee761f976c8f0e56e73cc85 "
1068
1068
dependencies :
1069
1069
react-native-modal "^13.0.1"
1070
1070
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @chatwoot/react-native-widget" ,
3
- "version" : " 0.0.14 " ,
3
+ "version" : " 0.0.16 " ,
4
4
"description" : " React Native widget for Chatwoot" ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ const WebViewComponent = ({
37
37
customAttributes,
38
38
closeModal,
39
39
} ) => {
40
+ const [ currentUrl , setCurrentUrl ] = React . useState ( null ) ;
40
41
let widgetUrl = `${ baseUrl } /widget?website_token=${ websiteToken } &locale=${ locale } ` ;
41
42
42
43
if ( cwCookie ) {
@@ -50,7 +51,10 @@ const WebViewComponent = ({
50
51
} ) ;
51
52
52
53
const onShouldStartLoadWithRequest = ( request ) => {
53
- const shouldRedirectToBrowser = ! widgetUrl . includes ( request . url ) ;
54
+ const isMessageView = currentUrl && currentUrl . includes ( '#/messages' ) ;
55
+ const isAttachmentUrl = ! widgetUrl . includes ( request . url ) ;
56
+ // Open the attachments only in the external browser
57
+ const shouldRedirectToBrowser = isMessageView && isAttachmentUrl ;
54
58
if ( shouldRedirectToBrowser ) {
55
59
Linking . openURL ( request . url ) ;
56
60
return false ;
@@ -59,6 +63,10 @@ const WebViewComponent = ({
59
63
return true ;
60
64
} ;
61
65
66
+ const handleWebViewNavigationStateChange = ( newNavState ) => {
67
+ setCurrentUrl ( newNavState . url ) ;
68
+ } ;
69
+
62
70
return (
63
71
< WebView
64
72
source = { {
@@ -89,6 +97,7 @@ const WebViewComponent = ({
89
97
style = { styles . WebViewStyle }
90
98
injectedJavaScript = { injectedJavaScript }
91
99
onShouldStartLoadWithRequest = { onShouldStartLoadWithRequest }
100
+ onNavigationStateChange = { handleWebViewNavigationStateChange }
92
101
scrollEnabled
93
102
/>
94
103
) ;
You can’t perform that action at this time.
0 commit comments