Regarding = Expo.Notifications.setBadgeNumberAsync(number)
Does anyone know how I would set that up in my code? We just want to show the (number) of new messages.
And, if possible - as message is “read” then it decrease by (x).
Here is my current code structure:
onSend = (message) => {
const notificationSetting = this.props.navigation.state.params.profile.notificationSetting
if (notificationSetting && notificationSetting.messagesPush) {
this._sendPush(message);
}
const { uid } = this.props.navigation.state.params.user
const profileUid = this.props.navigation.state.params.profileUid
firebase.database().ref(‘messages’).child(this.chatID).push({ …message[0], createdAt: firebase.database.ServerValue.TIMESTAMP, isRead:false})
firebase.database().ref(‘relationships’).child(profileUid).child(‘liked’)
.update({ [uid]: true })
//----//
firebase.database().ref(‘relationships’).child(uid).child(‘liked’)
.update({ [profileUid]: true })
}
_sendPush = (message) => {
const deviceToken = this.props.navigation.state.params.profile.deviceToken
const inAppSound = this.props.navigation.state.params.profile.notificationSetting.inAppSound
const { first_name, uid } = this.props.navigation.state.params.user
fetch(‘https://exp.host/--/api/v2/push/send’, {
method: ‘POST’,
headers: {
‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/json’,
},
body: JSON.stringify({
to: deviceToken,
title: “new message”,
//body: message[0].text,
body: first_name + ’ sent you a new message’,
sound: inAppSound ? ‘default’ : null,
badge: 1,
data:{
uid: uid
}
})
})
.then((response) => {
})
}