So I have a setup where I am trying to learn how to do a basic chat app with firebase and swift. I have the notification categories all setup, I can get the notifications, and I can click on the actions I have setup. I started upgrading it to allow a "reply" in the notification actions and that's where I am running into problems.
In my userNotificationCenter
method for didReceive
response, I need to be able to call my ApiService
to send the message off to my node server which communicates directly with firebase via the admin sdk. The problem is, every time I try to call a method from inside that function I get an error:
Type of expression is ambiguous without more context
Here is my didReceive
method, simplified for sake of simplicity in this post...
func userNotificaitonCenter(_ center: UNUsernotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfor = response.notificaiton.request.content.userInfo
switch response.actionIdentifier {
case Notifications.Actions.reply:
let textResponse = response as! UNTextInputNotificationResponse
let userText = textResponse.userText
let messageFrom = userInfo["from"]
let myID = userInfo["to"]
ApiService.sendNewMessage(myId, to: messageFrom, message: userText) { (_) in } <-This line gives the error
break
...
}
}
I have tried changing it by adding a private method in my AppDelegate
class and then calling that method, but I still get the same error. I don't understand why it thinks that expression is ambiguous, there is no other ApiService
class in my project except the one I built.
Am I doing this completely wrong? I just want to be able to send the message that the user typed in the notification back to the server so it can be added to the chat. Thank you for any help in advance, this one is making me scratch my head and lose some hair.