title: how to send silent notification / background notification using Firebase Cloud Messaging?
body: <p>I need to make silent notification/background notification in my iOS app using Firebase Cloud Messaging, so I can make an update in the app even though the user doesn't tap the push notification.</p>
  <p>the documentation from Apple about background notification is in <a href="https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app" rel="nofollow noreferrer">here</a> , it is said that</p>
  <blockquote>
  <p>To send a background notification, create a remote notification with
  an aps dictionary that includes only the content-available key in the payload</p>
  </blockquote>
  <p>Sample payload for a background notification from that documentation is like this:</p>
  <pre><code>{
     &quot;aps&quot; : {
        &quot;content-available&quot; : 1
     },
     &quot;acme1&quot; : &quot;bar&quot;,
     &quot;acme2&quot; : 42
  }
  </code></pre>
  <p>so I create my own payload when sending FCM using cloud function node JS. my code is like this</p>
  <pre><code>        const userToken = device.token
  
          const payload = {
              data: {
                  notificationID : notificationID,
                  creatorID : moderatorID,
                  creatorName: creatorName,
                  title : title,
                  body : body,
                  createdAt : now,
                  imagePath : imagePath,
                  type: type
              },
              apps : {
                  &quot;content-available&quot; : 1 // to force background data update in iOS 
              }
          }
  
         await admin.messaging().sendToDevice(userToken,payload)
  </code></pre>
  <p>I try to send and I have error:</p>
  <blockquote>
  <p>'Messaging payload contains an invalid &quot;apps&quot; property. Valid
  properties are &quot;data&quot; and &quot;notification&quot;.</p>
  </blockquote>
  <p>so adding &quot;apps&quot; property is not allowed, but iOS documentation said that I need to add &quot;content-available&quot; in the payload.</p>
  <p>I read other answer in <a href="https://stackoverflow.com/questions/63374137/is-there-a-callback-from-firebase-cloud-messaging-to-indicate-that-a-message-is/63374929?noredirect=1#comment112128629_63374929">here</a>, it is said that the payload should be written like this</p>
  <pre><code>{
  &quot;to&quot; : &quot;[token]&quot;,
  &quot;content_available&quot;: true,
  &quot;priority&quot;: &quot;high&quot;,
  &quot;data&quot; : {
    &quot;key1&quot; : &quot;abc&quot;,
    &quot;key2&quot; : abc
  }
  </code></pre>
  <p>but I am confused how to write the payload FCM that can trigger background notification in iOS</p>