title: How to post data to firestore from rich notification action?
body: <p>I have an application which implements remote notifications via firebase messaging api. In this app, I have implemented a notification service extension, which among others, implement UNNotificationActions.</p>
  <p>In one of these actions, I've implemented an input field where you can write something, which then should be posted to firestore.</p>
  <p>I've tried implementing this, but without success. So my question is how can I write to firestore from a rich notification running in the background - is this even possible?</p>
  <p>My implementation looks like this:</p>
  <pre><code>    let likeAction = UNNotificationAction(identifier: &quot;likeAction&quot;, title: &quot;Like&quot;, options: [])
      let commentAction = UNTextInputNotificationAction(identifier: &quot;commentAction&quot;, title: &quot;Comment&quot;, options: [UNNotificationActionOptions.authenticationRequired], textInputButtonTitle: &quot;Send&quot;, textInputPlaceholder: &quot;Type your message&quot;)
  
      let category = UNNotificationCategory(identifier: &quot;posts&quot;, actions: [likeAction, commentAction], intentIdentifiers: [], options: [])
      UNUserNotificationCenter.current().setNotificationCategories([category])
      
  </code></pre>
  <p>Then in AppDelegate, I implement the function to run whenever this is triggered like this:</p>
  <pre><code> func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -&gt; Void) {
      switch response.actionIdentifier {
      case &quot;commentAction&quot;:
        guard let data = response.notification.request.content.userInfo[&quot;data&quot;] as? [String: Any] else { return }
        
        guard
          let channelName = data[&quot;channelName&quot;],
          let postId = data[&quot;postId&quot;]
          else { return }
  
        if let message = response as? UNTextInputNotificationResponse {
          let documentPath = &quot;\(channelName)/\(postId))&quot;
          
          let post = Post()
          post.documentPath = documentPath
          post.addComment(text: message.userText, postDocumentPath: documentPath)
        }
  </code></pre>
  <p>I've debugged the code, and the method <code>post.addComment()</code> does actually get fired, and every field has a value. When I check the database, nothing gets inserted into it. The console prints out this, which I don't know if is related to the problem, I haven't been able to find anything online about these lines:</p>
  <blockquote>
  <p>dnssd_clientstub deliver_request ERROR: write_all(21, 65 bytes) failed</p>
  <p>nssd_clientstub read_all(26) DEFUNCT</p>
  </blockquote>
  <p>When running the post method, no error from firebase comes up.</p>
  <p>This was the initial information I could think of. I can provide more code or info if need be.</p>
  <p><strong>Update</strong></p>
  <p>I've discovered if I press the button while on lock screen, but with the iPhone in an unlocked state, nothing happens - as soon as I swipe up, and the app shows, the request gets send. This does indeed seem to be a background issue.</p>
  <p>Kind regards Chris</p>