Having In-App Notifications Vary By User in App

I am working on in-app notifications for my social media app that I'm programming using Parse and UIKit on Xcode 14.2. My main issue is that while the notification system itself is working, it's not varying by the user.

For example, say there are two users, User1 and User2. The way the notifications should be set up is when User1 likes User2's post or leaves a comment on User2's post, only User2 gets a notification saying "User1 liked your post!" or "User1 left a comment on your post!". However as of right now, when User1 likes or comment's on User2's post, User1 gets the notification saying "User1 liked your post!".

Here is the code that implements notifications in my app:

import UIKit
import Parse

class NotificationViewController: UIViewController, UITableViewDelegate, UITableViewDataSource
{

    @IBOutlet weak var tableView: UITableView!
    var notifications: [PFObject] = []

        override func viewDidLoad() {
            super.viewDidLoad()

            tableView.delegate = self
            tableView.dataSource = self

            
            NotificationCenter.default.addObserver(self, selector: #selector(didLikePost(_:)), name: NSNotification.Name("PostLikedByOtherUser"), object: nil)
            
           
            NotificationCenter.default.addObserver(self, selector: #selector(madeCommentOnPost(_:)), name: NSNotification.Name("CommentMade"), object: nil)

          
            let notificationClass = PFObject(className: "Notification")
            notificationClass["user"] = PFUser.current()
            notificationClass["fromUser"] = PFUser.current()
            notificationClass["post"] = PFObject(className: "Post")
            notificationClass.saveInBackground { (success, error) in
                if success {
                    print("Notification class created successfully")
                } else if let error = error {
                    print("Error creating notification class: \(error.localizedDescription)")
                }
            }
        }

        override func viewDidAppear(_ animated: Bool) {
            super.viewDidAppear(animated)

            
            let query = PFQuery(className: "Notification")
            query.whereKey("user", equalTo: PFUser.current()!)
            query.includeKey("fromUser")
            query.includeKey("post")
            query.order(byDescending: "createdAt")
            query.findObjectsInBackground { (objects, error) in
                if let error = error {
                    print("Error querying for notifications: \(error.localizedDescription)")
                } else if let notifications = objects {
                    self.notifications = notifications
                    self.tableView.reloadData()
                }
            }
        }

        func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
            return notifications.count
        }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
    {
        let cell = tableView.dequeueReusableCell(withIdentifier: "NotificationCell", for: indexPath) as! NotificationCell
        
        let notification = notifications[indexPath.row]
        let fromUser = notification["fromUser"] as! PFUser
        let post = notification["post"] as? PFObject
        
        cell.usernameLabel.text = fromUser.username
        
        if let username = fromUser.username, let post = post {
            if let likes = post["likes"] as? [PFObject], let _ = likes.first(where: { $0["liker"] as? String == PFUser.current()?.objectId }),
               post["user"] as? String == PFUser.current()?.objectId {
                cell.messageLabel.text = "You liked your own post."
            } else if let comments = post["comments"] as? [PFObject], let _ = comments.first(where: { $0["commenter"] as? String == PFUser.current()?.objectId }) {
                cell.messageLabel.text = "You liked \(username)'s post."
            } else if let _ = notification["comment"] {
                cell.messageLabel.text = "\(username) commented on your post."
            } else {
                cell.messageLabel.text = "\(username) liked your post."
            }
        }
        
        return cell
    }


   
    @objc func didLikePost(_ notification: Notification)
    {
        guard let post = notification.object as? PFObject,
            let postOwner = post["user"] as? PFUser,
            let liker = notification.userInfo?["liker"] as? PFUser,
            postOwner.objectId != liker.objectId,
            postOwner.objectId == PFUser.current()?.objectId else
        {
            return
        }

       
        let notificationObject = PFObject(className: "Notification")
        notificationObject["user"] = postOwner
        notificationObject["fromUser"] = liker
        notificationObject["post"] = post

        notificationObject.saveInBackground { (success, error) in
            if success
            {
                print("Successfully created notification")
            } else if let error = error
            {
                print("Error creating notification: \(error.localizedDescription)")
            }
        }
    }

    @objc func madeCommentOnPost(_ notification: Notification)
    {
        guard let comment = notification.object as? PFObject,
            let post = comment["post"] as? PFObject,
            let postOwner = post["user"] as? PFUser,
            let commenter = notification.userInfo?["commenter"] as? PFUser,
            postOwner.objectId != commenter.objectId,
            postOwner.objectId == PFUser.current()?.objectId else
        {
            return
        }

        let notificationObject = PFObject(className: "Notification")
        notificationObject["user"] = postOwner
        notificationObject["fromUser"] = commenter
        notificationObject["post"] = post

        notificationObject.saveInBackground { (success, error) in
            if success
            {
                print("Successfully created notification")
            } else if let error = error
            {
                print("Error creating notification: \(error.localizedDescription)")
            }
        }
    }
    deinit
    {
        NotificationCenter.default.removeObserver(self)
    }
}

I would really appreciate all the help on here.

Could it be this:

            notificationClass["user"] = PFUser.current()
            notificationClass["fromUser"] = PFUser.current()

The user and fromUser are the same -- PFUser.current().

Having In-App Notifications Vary By User in App
 
 
Q