Open
Description
Push Notifications are not working. When a message is sent the other user does not receive a notification. This is happening because the code that sends the notification is not being called. I would appreciate if anyone can fix it.
for notificationID in notificationIDs.values {
NotificationsController.send(to: notificationID, title: message.sender, message: message.text ?? Constants.Placeholders.pictureMessagePlaceholder)
}
This code is not being executed from the send message and no notifications is being sent.
func send(message: Message) {
// Write the message to Firebase
let randomMessageId = messagesRef!.childByAutoId().key
// Since we are sending this message, we can cache it as most recent
mostRecentMessageTimestamp = message.timestamp
// If there are inactive members, attempt to rejoin them
// Otherwise you would manually have to rejoin to be added again
for (uid, username) in inactiveMembers {
databaseManager.attemptRejoinIntoConversation(convoID: convoId, uid: uid, username: username, completion: {_ in})
}
// Each message record (uniquely identified) will record sender and message text
if let text = message.text {
messagesRef?.child(randomMessageId!).setValue(
["sender" : message.sender, "text" : text, "timestamp" : message.timestamp.timeIntervalSince1970]
)
} else if let imageURL = message.imageURL {
messagesRef?.child(randomMessageId!).setValue(
["imageURL": imageURL, "sender" : message.sender, "timestamp" : message.timestamp.timeIntervalSince1970]
)
}
// Set timestamp for most recent conversation viewing
// This is required to later determine if messages loaded have already been seen
updateLastSeenTimestamp(convoID: convoId)
// TODO: Internet speed may prevent sending notification if observers do not find out about newly reactivated users in time
// Ask NotificationController to send this message as a push notification
for notificationID in notificationIDs.values {
NotificationsController.send(to: notificationID, title: message.sender, message: message.text ?? Constants.Placeholders.pictureMessagePlaceholder)
}
}
Let me know if you know how to fix this issue!