Erik, Matthias,
Thanks for the comments and help.
I *think* we understand now what to do with setContentAvailable.
1. We get the silent notification telling the app that data is
available,. This is through the content-available flag - Working in our
app.
2. We use the silent notification to go get some more data (typically in
our case around 4-5KB) through an XHR call - Working in our app.
3 When we have got the data from our server and we have processed the
data, we call push.setContentAvailable with either NewData, NoData or
Failed as a parameter. This tells iOS that our background execution is
all down with and iOS can do whatever else it needs to - We have just
added this logic (well a single line) to our app at the end of our
functions, GetNotificationsFromServerSuccess() and
GetNotificationsFromServerFailure(). We have imaginative names on our
project :)
We have read the docs you supplied and quite a lot of others, including
other 3rd party push providers to try and understand it. Since
everything was working at our end without push.setContentAvailable() we
were puzzled as to its importance.
So all the push.setContentAvailable does is tell IOS we are finished
with background execution, and the parameter is the result of that
background execution? Its a tidy up function for iOS background
execution.
Thanks,
Rob
On 4 Dec 2015, at 8:03, Erik Jan de Wit wrote:
Hi Rob,
I think we talked about this before, but the silent
(content-available)
notifications are scheduled by iOS, e.g. there are some heuristic
involved.
And they are coupled to background content fetching, so when your app
receives a 'content-available' silent notification it has 30 seconds
to act
and afterwards it has to inform the os of the result. That is what
this
function is for, then the os can use this information along with how
often
it's used to schedule the next invocation. I agree we have a bit
sparse
documentation [1]. And also what apple writes is a bit sparse [2]. But
you
must set this result otherwise your app might not get invoked anymore.
In
the js api there is an enum with possible values that you can use [3]
[1]
https://aerogear.org/docs/guides/aerogear-cordova/AerogearCordovaPush/#_i...
[2]
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/i...
[3]
https://github.com/aerogear/aerogear-cordova-push/blob/master/www/aerogea...
On Fri, Dec 4, 2015 at 8:24 AM, Matthias Wessendorf
<matzew(a)apache.org>
wrote:
> yeah, I meant the flag. Glad it works for you.
>
> I am actually over asked on the client setContentAvailable().
>
>
> We have the same in our java sender, but that triggers the flag ;)
>
>
> On Thursday, 3 December 2015, Rob Willett
> <rob.aerogear(a)robertwillett.com>
> wrote:
>
>> Matthia,
>>
>> Thanks for this. Are you referring to content-available flag or the
>> setContentAvailable function?
>>
>> We already send silent notifications out to our Android and Apple
>> devices and the devices handle these correctly.
>>
>> Our logic goes that we send a silent notification to the device via
>> UPS,
>> the device then connects to the server and pulls some data from the
>> server. If our app is in the foreground, we set a tiny alert in the
>> top
>> left of the screen telling the user that something is ready for
>> them, if
>> our app is in the background we set a notification up in the drawer
>> using a local-notification plugin, if the app is not started then
>> the
>> fact the app has not pulled data from the server acts as a flag and
>> we
>> then send down full notifications to the device. The
>> local-notifications
>> and the ‘full fat’ notifications all work the same way when the
>> user
>> clicks on them.
>>
>> We have all of this is working now without setContentAvailable. Its
>> much
>> as you outlined below. I have two phones on my desk as we speak, an
>> Apple and an Android and we are comparing how the notifications look
>> as
>> we ping different data down to them in different situations. We’re
>> down to design looks now rather than programming :)
>>
>> We’re just trying to work out how setContentAvailable fits into
>> all of
>> this, because we aren’t using it at all! Should we be?
>>
>> Rob
>>
>> On 3 Dec 2015, at 18:23, Matthias Wessendorf wrote:
>>
>>> Hi,
>>>
>>> it's an iOS feature, that you can use for having the app download
>>> something
>>> (or check state on your backend), before the alert is being made
>>> visible to
>>> the end-user:
>>>
>>
https://developer.xamarin.com/guides/ios/application_fundamentals/backgro...
>>>
>>>
>>> Also (more interesting, I think) you can use it to send a slient
>>> message to
>>> the device. E.g. when the app runs (fore/background) the callback
>>> is
>>> invoked. You can use that to check state on your own backend (a 30
>>> second
>>> time window, you have for this), and if needed you could use that
>>> to,
>>> for
>>> instance, issue something local e.g. local notifications (those are
>>> better
>>> and more handy for several reasons e.g. better control of the badge
>>> icon):
>>>
>>
https://developer.xamarin.com/guides/ios/application_fundamentals/backgro...
>>>
>>> HTH,
>>> Matthias
>>>
>>>
>>> On Thu, Dec 3, 2015 at 7:01 PM, Rob Willett
>>> <rob.aerogear(a)robertwillett.com>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> We now seem to have something approaching a stable and working UPS
>>>> configuration. (Famous last words!) Thanks to the Aerogear team
>>>> for
>>>> helping
>>>> resolve the background notifications on Android.
>>>>
>>>> As we are tidying up, we noticed (ahem) that we had commented out
>>>> a
>>>> few
>>>> lines in our code.
>>>>
>>>> if (event['content-available'])
>>>> {
>>>> // Still not clear what to do with this.
>>>> // push.setContentAvailable(1);
>>>> }
>>>>
>>>> We went back to the Aerogear docs and tried to work out what
>>>> setContentAvailable really does and what should we do with it. The
>>>> docs for
>>>> the function call are a little sparse, so we looked at the source
>>>> code and
>>>> we’re still no wiser.
>>>>
>>>> Is there a better explanation of when we should call
>>>> setContentAvailable
>>>> and with which parameter?
>>>>
>>>> Just to set the ball rolling we *think* it could mean that when
>>>> you
>>>> receive the content-available = 1 flag on iOS, we do a call to get
>>>> some
>>>> data from the server ourselves, if the the results of *our* server
>>>> call
>>>> indicate that we have received new data, we set the value to
>>>> setContentAvailable to 1, if our function call to the server has
>>>> no
>>>> data,
>>>> then we set it to zero and if something failed we set it to 2.
>>>>
>>>> So what happens if the value is 0, 1 or 2? if its 2, is a new new
>>>> call
>>>> made to something, if its 0 or 1 what happens?
>>>>
>>>> Apologies if we’ve missed the point of it, but we’re
>>>> struggling
>>>> to
>>>> understand this.
>>>>
>>>> Thanks,
>>>>
>>>> Rob.
>>>>
>>>> _______________________________________________
>>>> Aerogear-users mailing list
>>>> Aerogear-users(a)lists.jboss.org
>>>>
https://lists.jboss.org/mailman/listinfo/aerogear-users
>>>>
>>>>
>>>
>>>
>>> --
>>> Matthias Wessendorf
>>>
>>> blog:
http://matthiaswessendorf.wordpress.com/
>>> sessions:
http://www.slideshare.net/mwessendorf
>>> twitter:
http://twitter.com/mwessendorf
>>> _______________________________________________
>>> Aerogear-users mailing list
>>> Aerogear-users(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/aerogear-users
>>
>> _______________________________________________
>> Aerogear-users mailing list
>> Aerogear-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/aerogear-users
>>
>
>
> --
> Sent from Gmail Mobile
>
> _______________________________________________
> Aerogear-users mailing list
> Aerogear-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/aerogear-users
>
>
--
Cheers,
Erik Jan
_______________________________________________
Aerogear-users mailing list
Aerogear-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-users