<div class="markdown">
<p dir="auto">On 15 Dec 2015, at 12:43, Erik Jan de Wit wrote:</p>

<pre><code>&gt; Yes it should also start your app when the app is not running or suspended,
&gt; but it depends on heuristics of how much the user uses your app also
&gt; something to keep in mind is that:
</code></pre>

<p dir="auto">These heuristics seem arbitrary and undefined to us.</p>

<pre><code>&gt; If the user rebooted his device and never launched the app since the
&gt; reboot, the app will never wake up remotely and if the user killed the app
&gt; manually from the app switcher, the app will also never wake up remotely.
</code></pre>

<p dir="auto">So basically the user has to start the app and never kill it. Just put it to the background and leave it there.</p>

<pre><code>&gt; I created a small app similar to your use-case where I do a http request
&gt; when the content-available flag is set:
&gt;
&gt; onNotification: function(event) {
&gt;   if (event['content-available'] === 1) {
&gt;       ajax({
&gt;           url: "http://192.168.0.30:8888/index.php",
&gt;           dataType: "text"
&gt;       })
&gt;       .then( function( result ) {
&gt;           console.log(result);
&gt;           push.setContentAvailable(push.FetchResult.NewData);
&gt;       });
&gt;   }

&gt; When I send a message with only content-available set like this:
&gt;
&gt; ~/w/t/background-fetch ❯❯❯ curl -u
&gt; "73795055-123-462d-a6dd-4ad514c3afbf:123456-617f-47d4-a03b-f9ce89b7ec2b"
&gt; \
&gt; -v -H "Accept: application/json" -H "Content-type: application/json"  \
&gt; -X POST  -d \'{"message": {"content-available" : true}}'
&gt; \https://ups-me.rhcloud.com/ag-push/rest/sender
&gt;
&gt;
&gt; It sometimes calls my server, but not always and sometimes takes some time
&gt; to activate the app. Again this is something that apple implemented the app
&gt; is woken up / started by the os and there is nothing we can do about this.
&gt;
&gt; You could also send a notification + content-available that way the
&gt; notification can be used to start the app or if there was no network the
&gt; app will react before the user 'touches' the app.
</code></pre>

<p dir="auto">Mmmm this is similar to what happens to our code. We have had things happen in the background or suspended state (or what we thought was suspended), but its not clear whats going on. We haven’t had success recently hence our e-mail, we’ll keep looking into this and see if we can get anything clearer. One option was to look at doing an explicit background fetch every hour or so, to see if we can jiggle the app into a better state or to clear out local notifications. It may well be that we are pushing Apples idea of what notifications can or should do just too far and we should accept the limitations and work with them. </p>

<p dir="auto">We had tried the content-available AND a notification but that didn’t seem to work. We’ll try again now we have a better understanding. </p>

<p dir="auto">Thanks again.</p>

<p dir="auto">Rob</p>

</div>