Skip to content

Commit ff3c0ab

Browse files
feat(example): customize chat settings (#1156)
* feat(example): customize chat settings * feat(example): customize chat settings * fix: pr comments
1 parent 41157fc commit ff3c0ab

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

examples/default/src/screens/RepliesScreen.tsx

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,73 @@ import { Heading } from 'native-base';
55

66
import { ListTile } from '../components/ListTile';
77
import { Screen } from '../components/Screen';
8+
import { Switch } from 'react-native';
9+
import { PlatformListTile } from '../components/PlatformListTile';
810

911
export const RepliesScreen: React.FC = () => {
1012
const [count, setCount] = useState<number>();
13+
const [isNotificationEnable, setIsNotificationEnable] = useState<boolean>(true);
14+
const [isPushNotificationEnable, setIsPushNotificationsEnable] = useState<boolean>(true);
15+
const [isAppReplayNotificationSoundEnable, setIsAppReplayNotificationSoundEnable] =
16+
useState<boolean>(false);
17+
const [isSystemReplayNotificationSound, setIsSystemReplayNotificationSound] =
18+
useState<boolean>(false);
1119

1220
useEffect(() => {
13-
Replies.getUnreadRepliesCount(setCount);
21+
Replies.getUnreadRepliesCount().then((unReadCount) => {
22+
setCount(unReadCount);
23+
});
1424
}, []);
1525

1626
return (
1727
<Screen>
28+
<ListTile title="Enable notification">
29+
<Switch
30+
value={isNotificationEnable}
31+
onValueChange={(value) => {
32+
setIsNotificationEnable(value);
33+
Replies.setEnabled(value);
34+
}}
35+
/>
36+
</ListTile>
37+
<ListTile title="InApp Replay notification Sound">
38+
<Switch
39+
value={isAppReplayNotificationSoundEnable}
40+
onValueChange={(value) => {
41+
setIsAppReplayNotificationSoundEnable(value);
42+
Replies.setInAppNotificationSound(value);
43+
}}
44+
/>
45+
</ListTile>
46+
<PlatformListTile title="System replay notification Sound" platform="android">
47+
<Switch
48+
value={isSystemReplayNotificationSound}
49+
onValueChange={(value) => {
50+
setIsSystemReplayNotificationSound(value);
51+
Replies.setSystemReplyNotificationSoundEnabledAndroid(value);
52+
}}
53+
/>
54+
</PlatformListTile>
55+
<PlatformListTile title="Push notification enable" platform="android">
56+
<Switch
57+
value={isPushNotificationEnable}
58+
onValueChange={(value) => {
59+
setIsPushNotificationsEnable(value);
60+
Replies.setPushNotificationsEnabled(value);
61+
}}
62+
/>
63+
</PlatformListTile>
1864
<ListTile title="Unread Messages">
1965
<Heading size="sm" textAlign="right">
2066
{count ?? '...'}
2167
</Heading>
2268
</ListTile>
69+
<ListTile
70+
title="Show conversion list"
71+
onPress={() => {
72+
Replies.show();
73+
}}
74+
/>
2375
</Screen>
2476
);
2577
};

0 commit comments

Comments
 (0)