Silent iOS Push Notification with React Native when app is in background
<p>I have a React Native app where I am trying to get a silent iOS push notification sent to a handler in JavaScript.</p>

<p>The behaviour I am seeing is that the <code>didReceiveRemoteNotification</code> function in <code>AppDelegate</code> gets called but my handler in JavaScript doesn't get called unless the app is in the foreground or has only been closed recently.</p>

<p>The thing I am confused about is clearly the app is being woken up and having it's <code>didReceiveRemoteNotification</code> function called, but then the call to <code>[RCTPushNotificationManager didReceiveRemoteNotification:notification]</code> doesn't seem to do anything.</p>

<p>Also, if I open the app after a notification has been received, then I see the React Native handler is called at that point.</p>

<p>My <code>didReceiveRemoteNotification</code> function looks like this:</p>

<pre><code>- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification
{
  NSLog(@"didReceiveRemoteNotification");

  [RCTPushNotificationManager didReceiveRemoteNotification:notification];
}
</code></pre>

<p>In the Root component of my React Native app I have this:</p>

<pre><code>componentDidMount() {
    AppState.addEventListener('change', this.handleAppStateChange);

    PushNotificationIOS.addEventListener('notification', (notification) =&gt; {
        console.log("notification recieved");
    })
}
handleAppStateChange(currentAppState) {
    console.log(currentAppState);
}
</code></pre>

<p>I am sending a push notification using AWS SNS with the following message:</p>

<pre><code>{
"APNS_SANDBOX":"{\"aps\":{\"content-available\":\"1\"}}"
}
</code></pre>

<p>Here is the log from XCode:</p>

<pre><code>2016-04-20 10:38:01.255 [info][tid:com.facebook.React.JavaScript] inactive
2016-04-20 10:38:01.986 [info][tid:com.facebook.React.JavaScript] background
2016-04-20 10:38:17.279 test[4056:1383261] didReceiveRemoteNotification
2016-04-20 10:38:17.284 [info][tid:com.facebook.React.JavaScript] notification recieved
2016-04-20 10:44:56.330 test[4056:1383261] didReceiveRemoteNotification
2016-04-20 10:44:56.332 [info][tid:com.facebook.React.JavaScript] notification recieved
2016-04-20 10:46:07.091 test[4056:1383261] didReceiveRemoteNotification
2016-04-20 10:49:30.039 [info][tid:com.facebook.React.JavaScript] notification recieved
2016-04-20 10:49:30.639 [info][tid:com.facebook.React.JavaScript] active
</code></pre>

<p>In this log, 3 push notifications where sent. The ones received at 10:38 and 10:44 both called JavaScript correctly.
However, the one received at 10:46 didn't call the handler in JavaScript until I opened the app at 10:49.</p>

<p>Is there anything I can do to ensure the call to my React Native code occurs even with app not running?</p>