title: Swift Group push notifications
body: <p>i have social network app and... i want to know if there are possibility to group notifications on lock screen by this app.</p>
  
  <p>My remote server send notification to APNs, then i receive it by device token. Is there any way to group notifications by app? I found code on medium, but i don't know how to implement it. </p>
  
  <p><a href="https://medium.com/swift-india/lets-take-quick-dive-in-grouped-notifications-5d41af9d6463" rel="nofollow noreferrer">https://medium.com/swift-india/lets-take-quick-dive-in-grouped-notifications-5d41af9d6463</a></p>
  
  <pre><code>func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -&gt; Void) {
  
      //over here add condition if same user has opened chat and notification is also from same user dont show these
      let extraPayLoad = (notification.request.content.userInfo["extraPayLoad"] as? [AnyHashable : Any])
      if extraPayLoad!["custom"] != nil {
          let info_string = extraPayLoad!["custom"] as? String
  
          let objectData: Data? = info_string?.data(using: String.Encoding(rawValue: String.Encoding.utf8.rawValue))
          var json: [AnyHashable : Any]? = nil
          if let aData = objectData {
              json = try! JSONSerialization.jsonObject(with: aData, options: .mutableContainers) as? [AnyHashable : Any]
          }
          if json?["sender_id"] != nil {
              if let aKey = json?["sender_id"] {
                  print("sender_id : \(aKey)")
              }
  
              if(json?["code"] as? Int ?? 0 != 1003 &amp;&amp; json?["code"] as? Int ?? 0 != 1004)
              {
                  let unread_count_dict:[String: Bool] = ["unread_count":  true]
                  NotificationCenter.default.post(name: NSNotification.Name(rawValue: "showNotificationView"), object: nil, userInfo: unread_count_dict)
              }
              if (UserDefaults.standard.value(forKey: "_targetId") as? String ?? "0") == "\((json?["sender_id"] as? Int ?? -1))" {
                  //
                  // NotificationCenter.default.post(name: NSNotification.Name("GetAllConversationsList"), object: self)
                  //return
              }
              if (UserDefaults.standard.value(forKey: "_groupId") as? String ?? "0") == "\((json?["group_id"] as? Int ?? -1))" {
                  // NotificationCenter.default.post(name: NSNotification.Name("GetAllConversationsList"), object: self)
                  //return
              }
  
          }
      }
      completionHandler([.sound, .alert, .badge])
  }
  </code></pre>