-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
100 lines (92 loc) · 2.99 KB
/
App.js
File metadata and controls
100 lines (92 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import * as React from 'react';
import PushNotification from "react-native-push-notification"
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Icon from 'react-native-vector-icons/Ionicons';
import Sobre from './src/Screens/Sobre';
import HomeStack from './src/Navigation/HomeStack';
// Adding notifications
PushNotification.createChannel(
{
channelId: "channel-id",
channelName: "My channel",
channelDescription: "A channel to categorise your notifications",
playSound: false,
soundName: "default",
vibrate: true,
},
(created) => console.log(`createChannel returned '${created}'`)
);
PushNotification.configure({
onRegister: function (token) {
console.log("[NotificationManager] onRegister token:", token);
},
onNotification: function (notification) {
console.log("[NotificationManager] onNotification:", notification);
},
onAction: function(notification){
console.log("ACTION:", notification.action)
}
})
// Adding scheduled notifications
// Notifications scheduled to cycle every 3 hours
PushNotification.localNotificationSchedule({
id:1,
channelId: 'channel-id',
title: 'Pensando em fazer um Lanche?',
message: "Confira essas ótimas receitas para matar a vontade!",
date: new Date(Date.now() + 10800 * 1000),// 3h
allowWhileIdle: false,
repeatTime: 21600*1000,// 6h
repeatType: 'time'
});
PushNotification.localNotificationSchedule({
id:2,
channelId: 'channel-id',
title: 'Sua sede não é de água',
message: "Confira essas ótimas receitas para matar a vontade!",
date: new Date(Date.now() + 21600 * 1000),// 6h
allowWhileIdle: false,
repeatTime: 21600*1000,// 6h
repeatType: 'time'
});
// Finishing adding notifications
// Adding my own theme to the Navigation Container
const MyTheme = {
dark: false,
colors: {
background: '#fff8e7',
card: '#ffe5c3',
text: '#442C2E',
},
};
const Tab = createBottomTabNavigator();
export default function App() {
return (
<NavigationContainer theme={MyTheme}>
<Tab.Navigator
// Adding Icons to the bottontab
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let iconName;
if (route.name === 'Home') {
iconName = focused
? 'home'
: 'home-outline';
} else if (route.name === 'Sobre') {
iconName = focused
? 'md-business'
: 'md-business-outline';
}
return <Icon name={iconName} size={size} color={color} />;
},
})} tabBarOptions={{
activeTintColor: '#442C2E',
inactiveTintColor: '#442C2E'
}}>
<Tab.Screen name="Home" component={HomeStack} options={{ title: 'Receitas Caseiras' }} />
<Tab.Screen name="Sobre" component={Sobre} />
</Tab.Navigator>
</NavigationContainer>
);
}