Firebase messaging not working for "data" messages in iOS
<p>I have an app running on iOS 9.3.5. I need to be able to send a push notification to my app when it's in the foreground or background. I don't actually need to include any data, I just need to ping the app so it will "<em>phone home</em>". So I don't need/want the user to see any notifications.</p>

<p>Since the company is already using Firebase for their Android app, I've set that up in the iOS app. If I send a message to <code>https://fcm.googleapis.com/fcm/send</code> with the <code>notification</code> key in the payload, it's received on the iPhone. When I try it with the <code>data</code> key instead, I get nothing. In both cases I get a <code>success</code> response from the POST. I've implemented the follow callbacks:</p>

<pre><code>application:didReceiveRemoteNotification:
userNotificationCenter:willPresentNotification:withCompletionHandler:
applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage
</code></pre>

<p>None of those are called when sending a message with the <code>data</code> key.</p>

<p>Edit:
This is the payload I'm using.</p>

<blockquote>
  <p>{ "data": {
     "message": "phonehome",
   },
   "to" : "xxxxx"
  }</p>
</blockquote>

<p>After doing some more testing it looks like I get that message when the app is in the foreground but not the background. When I switch to the foreground then <code>application:didReceiveRemoteNotification:</code> gets called.</p>

<p>Edit 2: Added <code>content_available</code> and that did the trick. Thanks!</p>

<blockquote>
  <p>{   "to" : "xxxx", "content_available" : true }</p>
</blockquote>