Skip to content

Commit

Permalink
Merge pull request #41 from idanlevi1/master
Browse files Browse the repository at this point in the history
Release to Google Play for the Android platform.
  • Loading branch information
idanlevi1 committed Sep 16, 2018
2 parents fc5f59c + 47f6ceb commit e87a985
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "מהפכה של שמחה",
"description": "אפליקציה לעידוד התנדבויות בבתי חולים",
"slug": "StartachHapRev",
"version": "1.0.0",
"version": "1.0.1",
"icon": "./src/images/haprevLogo.png",
"sdkVersion": "25.0.0",
"privacy": "public",
Expand Down
36 changes: 34 additions & 2 deletions src/views/adminActivities/CreateActivityView.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { Component } from 'react';
import {View, Text, TextInput, KeyboardAvoidingView, Keyboard, TouchableOpacity, Modal, TouchableWithoutFeedback} from "react-native";
import {View, Text, TextInput, KeyboardAvoidingView, Keyboard, TouchableOpacity, Modal, TouchableWithoutFeedback, Switch, ActivityIndicator} from "react-native";
import DateTimePicker from 'react-native-modal-datetime-picker';
import {CreateActivityStyle as styles } from './styles';
import {sendNotificationToAllUsers} from '../notification/NotificationService';

class CreateActivityView extends Component {
constructor(props) {
Expand All @@ -18,6 +19,8 @@ class CreateActivityView extends Component {
isButtonDisabled: true,
modalVisible:false,
success:false,
notificationToAll:true,
loading:false,
};
}
_showDateTimePicker = () => {
Expand Down Expand Up @@ -47,6 +50,19 @@ class CreateActivityView extends Component {
res = await this.props.onNewActivityHandler(this.state.fullDate,this.state.fullTime,this.state.activityName,this.state.fullFormatDate)
if(res === 'ok')
this.setState({success : true});
//send notification to all users
if(this.state.notificationToAll){
const { hospital, first, last } = this.props;
let activity = {
hospital: hospital,
coordinatorName: first +' '+ last,
nameActivity: this.state.activityName,
time: this.state.fullDate,
}
this.setState({loading:true})
await sendNotificationToAllUsers(activity)
this.setState({loading:false})
}
this.setState({modalVisible : true});
}
else{
Expand Down Expand Up @@ -100,12 +116,28 @@ class CreateActivityView extends Component {
: this.alertDate
}
</Text>
<View style={{flexDirection:'row',justifyContent: "center"}}>
<Text style={{fontSize: 14,color:'#B93A32'}}>לשלוח התראות על האירוע לכל המשתמשים?</Text>
<Switch
onTintColor={'#00A591'}
thumbTintColor={ this.state.notificationToAll ? '#79C753' : '#898E8C'}
tintColor={'#B93A32'}
style= {styles.switch}
onValueChange={() => this.setState({notificationToAll:!this.state.notificationToAll})}
value={this.state.notificationToAll}
/>
</View>
<TouchableOpacity
rounded
disabled = {this.state.isButtonDisabled}
disabled = {this.state.isButtonDisabled || this.state.loading}
onPress={this.createNewActivity}
style={[styles.button, this.state.isButtonDisabled ? { backgroundColor:'#c6c6c6'} : { }]}>
{
!this.state.loading ?
<Text style={styles.buttonText}>אישור</Text>
:
<ActivityIndicator size='large' color='#FFFFFF' />
}
</TouchableOpacity>
</View>
</TouchableWithoutFeedback>
Expand Down
14 changes: 14 additions & 0 deletions src/views/notification/NotificationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,18 @@ export const getUserTokenNotification = async(userId) =>{
})
.catch(error => {console.log('Error ' + error);})
return userToken
}

export const sendNotificationToAllUsers = async(activity) =>{
let titleMsg = 'פעילות חדשה ב' +hospital + ' ב' +time;
let contentMsg = 'הפעילות ' + nameActivity + ' עם הרכז ' + coordinatorName + ' מוזמנים להרשם!';
firebase.database().ref('users').once('value' ,
snapshot => {
var users = snapshot.val()
var usersList = Object.keys(users).map((u,k) => {return users[u].settings && users[u].settings.token!=='' && users[u].settings.token})
.filter(x=> x&&x)
usersList.forEach(userToken=>{
sendPushNotification(userToken,titleMsg,contentMsg)
})
})
}

0 comments on commit e87a985

Please sign in to comment.