On 15 Dec 2015, at 12:43, Erik Jan de Wit wrote:
```
Yes it should also start your app when the app is not running or
suspended,
but it depends on heuristics of how much the user uses your app also
something to keep in mind is that:
```
These heuristics seem arbitrary and undefined to us.
```
If the user rebooted his device and never launched the app since the
reboot, the app will never wake up remotely and if the user killed the
app
manually from the app switcher, the app will also never wake up
remotely.
```
So basically the user has to start the app and never kill it. Just put
it to the background and leave it there.
```
I created a small app similar to your use-case where I do a http
request
when the content-available flag is set:
onNotification: function(event) {
if (event['content-available'] === 1) {
ajax({
url: "http://192.168.0.30:8888/index.php",
dataType: "text"
})
.then( function( result ) {
console.log(result);
push.setContentAvailable(push.FetchResult.NewData);
});
}
When I send a message with only content-available set like this:
~/w/t/background-fetch ❯❯❯ curl -u
"73795055-123-462d-a6dd-4ad514c3afbf:123456-617f-47d4-a03b-f9ce89b7ec2b"
\
-v -H "Accept: application/json" -H "Content-type: application/json"
\
-X POST -d \'{"message": {"content-available" : true}}'
\https://ups-me.rhcloud.com/ag-push/rest/sender
It sometimes calls my server, but not always and sometimes takes some
time
to activate the app. Again this is something that apple implemented
the app
is woken up / started by the os and there is nothing we can do about
this.
You could also send a notification + content-available that way the
notification can be used to start the app or if there was no network
the
app will react before the user 'touches' the app.
```
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.
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.
Thanks again.
Rob