1 | |||
2 | import {Platform} from 'react-native'; |
||
3 | import { Notifications } from 'expo'; |
||
4 | import * as Permissions from 'expo-permissions'; |
||
5 | |||
6 | const newChanneler = { |
||
7 | // create a new channel |
||
8 | newChannel: ( name, isSound )=>{ |
||
9 | switch(isSound){ |
||
10 | case false: |
||
11 | if (Platform.OS === 'android') { |
||
12 | Notifications.createChannelAndroidAsync(name, { |
||
13 | name: name, |
||
14 | sound: false, |
||
15 | }); |
||
16 | return true; |
||
17 | }else{ |
||
0 ignored issues
–
show
Comprehensibility
introduced
by
![]() |
|||
18 | alert('newChannel is not supported on IOS') |
||
0 ignored issues
–
show
Debugging Code
Best Practice
introduced
by
|
|||
19 | } |
||
20 | break; |
||
0 ignored issues
–
show
|
|||
21 | |||
22 | case true: |
||
23 | if (Platform.OS === 'android') { |
||
24 | Notifications.createChannelAndroidAsync(name, { |
||
25 | name: name, |
||
26 | sound: true, |
||
27 | }); |
||
28 | return true; |
||
29 | }else{ |
||
0 ignored issues
–
show
|
|||
30 | alert('newChannel is not supported on IOS') |
||
31 | } |
||
32 | break; |
||
0 ignored issues
–
show
|
|||
33 | |||
34 | default: |
||
35 | if (Platform.OS === 'android') { |
||
36 | Notifications.createChannelAndroidAsync(name, { |
||
37 | name: name, |
||
38 | sound: false, |
||
39 | }); |
||
40 | return true; |
||
41 | }else{ |
||
0 ignored issues
–
show
|
|||
42 | alert('newChannel is not supported on IOS') |
||
43 | } |
||
44 | break; |
||
0 ignored issues
–
show
|
|||
45 | |||
46 | } |
||
47 | |||
48 | }, |
||
49 | |||
50 | |||
51 | } |
||
52 | |||
53 | export default newChanneler; |