Notifications (ios10), Firebase Push Notifications and Remote Notifications

130 views Asked by At

Our project uses Firebase and we have followed all the steps to make it work. The only problem is that we cannot seem to send notifications to all users to a specific Firebase Group. That is a set of users that belong to a group.

We receive notifications when we use the Firebase Console, but when we trigger a notification from the app, the only user that gets notified is the one that sent it.

Here is the code I use when the user taps to send the notification

func scheduleNotificationTakeaways(inSeconds: TimeInterval, completion: @escaping (_ Success: Bool) -> ()) {

        let notif = UNMutableNotificationContent()

        notif.categoryIdentifier = "myNotificationCategory"

        if takeaways.count > 0 {

            notif.title = "Order ready!"
            notif.subtitle = "For Takeaway # \(takeaways[currentIndex].number!)"
            notif.body = "Order ready to collect for Takeaway # \(takeaways[currentIndex].number!)"

            let notifTrigger = UNTimeIntervalNotificationTrigger(timeInterval: inSeconds, repeats: false)


            let request = UNNotificationRequest(identifier: "myNotification", content: notif, trigger: notifTrigger)


            UNUserNotificationCenter.current().add(request, withCompletionHandler: { error in
                if error != nil {
                    print(error)
                    completion(false)
                } else {
                    completion(true)
                }
            })
        }
    }

Instead of working this notifications locally, we would like to have these notifications appear for specific users or a specific Firebase Group.

0

There are 0 answers