Skip to content

Commit e87a985

Browse files
authored
Merge pull request #41 from idanlevi1/master
Release to Google Play for the Android platform.
2 parents fc5f59c + 47f6ceb commit e87a985

File tree

4 files changed

+52
-3
lines changed

4 files changed

+52
-3
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"git.ignoreLimitWarning": true
3+
}

app.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "מהפכה של שמחה",
44
"description": "אפליקציה לעידוד התנדבויות בבתי חולים",
55
"slug": "StartachHapRev",
6-
"version": "1.0.0",
6+
"version": "1.0.1",
77
"icon": "./src/images/haprevLogo.png",
88
"sdkVersion": "25.0.0",
99
"privacy": "public",

src/views/adminActivities/CreateActivityView.js

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, { Component } from 'react';
2-
import {View, Text, TextInput, KeyboardAvoidingView, Keyboard, TouchableOpacity, Modal, TouchableWithoutFeedback} from "react-native";
2+
import {View, Text, TextInput, KeyboardAvoidingView, Keyboard, TouchableOpacity, Modal, TouchableWithoutFeedback, Switch, ActivityIndicator} from "react-native";
33
import DateTimePicker from 'react-native-modal-datetime-picker';
44
import {CreateActivityStyle as styles } from './styles';
5+
import {sendNotificationToAllUsers} from '../notification/NotificationService';
56

67
class CreateActivityView extends Component {
78
constructor(props) {
@@ -18,6 +19,8 @@ class CreateActivityView extends Component {
1819
isButtonDisabled: true,
1920
modalVisible:false,
2021
success:false,
22+
notificationToAll:true,
23+
loading:false,
2124
};
2225
}
2326
_showDateTimePicker = () => {
@@ -47,6 +50,19 @@ class CreateActivityView extends Component {
4750
res = await this.props.onNewActivityHandler(this.state.fullDate,this.state.fullTime,this.state.activityName,this.state.fullFormatDate)
4851
if(res === 'ok')
4952
this.setState({success : true});
53+
//send notification to all users
54+
if(this.state.notificationToAll){
55+
const { hospital, first, last } = this.props;
56+
let activity = {
57+
hospital: hospital,
58+
coordinatorName: first +' '+ last,
59+
nameActivity: this.state.activityName,
60+
time: this.state.fullDate,
61+
}
62+
this.setState({loading:true})
63+
await sendNotificationToAllUsers(activity)
64+
this.setState({loading:false})
65+
}
5066
this.setState({modalVisible : true});
5167
}
5268
else{
@@ -100,12 +116,28 @@ class CreateActivityView extends Component {
100116
: this.alertDate
101117
}
102118
</Text>
119+
<View style={{flexDirection:'row',justifyContent: "center"}}>
120+
<Text style={{fontSize: 14,color:'#B93A32'}}>לשלוח התראות על האירוע לכל המשתמשים?</Text>
121+
<Switch
122+
onTintColor={'#00A591'}
123+
thumbTintColor={ this.state.notificationToAll ? '#79C753' : '#898E8C'}
124+
tintColor={'#B93A32'}
125+
style= {styles.switch}
126+
onValueChange={() => this.setState({notificationToAll:!this.state.notificationToAll})}
127+
value={this.state.notificationToAll}
128+
/>
129+
</View>
103130
<TouchableOpacity
104131
rounded
105-
disabled = {this.state.isButtonDisabled}
132+
disabled = {this.state.isButtonDisabled || this.state.loading}
106133
onPress={this.createNewActivity}
107134
style={[styles.button, this.state.isButtonDisabled ? { backgroundColor:'#c6c6c6'} : { }]}>
135+
{
136+
!this.state.loading ?
108137
<Text style={styles.buttonText}>אישור</Text>
138+
:
139+
<ActivityIndicator size='large' color='#FFFFFF' />
140+
}
109141
</TouchableOpacity>
110142
</View>
111143
</TouchableWithoutFeedback>

src/views/notification/NotificationService.js

+14
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,18 @@ export const getUserTokenNotification = async(userId) =>{
5757
})
5858
.catch(error => {console.log('Error ' + error);})
5959
return userToken
60+
}
61+
62+
export const sendNotificationToAllUsers = async(activity) =>{
63+
let titleMsg = 'פעילות חדשה ב' +hospital + ' ב' +time;
64+
let contentMsg = 'הפעילות ' + nameActivity + ' עם הרכז ' + coordinatorName + ' מוזמנים להרשם!';
65+
firebase.database().ref('users').once('value' ,
66+
snapshot => {
67+
var users = snapshot.val()
68+
var usersList = Object.keys(users).map((u,k) => {return users[u].settings && users[u].settings.token!=='' && users[u].settings.token})
69+
.filter(x=> x&&x)
70+
usersList.forEach(userToken=>{
71+
sendPushNotification(userToken,titleMsg,contentMsg)
72+
})
73+
})
6074
}

0 commit comments

Comments
 (0)