Issues (7)

Helpers/newChannel.js (7 issues)

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
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
18
                                alert('newChannel is not supported on IOS')
0 ignored issues
show
Debugging Code Best Practice introduced by
The alert UI element is often considered obtrusive and is generally only used as a temporary measure. Consider replacing it with another UI element.
Loading history...
19
                              }
20
                        break;
0 ignored issues
show
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
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
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
30
                                alert('newChannel is not supported on IOS')
31
                              }
32
                        break;
0 ignored issues
show
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
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
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
42
                                alert('newChannel is not supported on IOS')
43
                              }
44
                        break;
0 ignored issues
show
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
45
46
          }
47
48
    },
49
50
51
}
52
53
export default newChanneler;