04-06-2011 05:53 PM
Hi everyone it's a month now that i'm reading these forums and they helped me a lot in getting my app working, so first of all i want to greet an thank you.
Now i'm going into adding push functionality and since i'm developing for 5 and 6 apis i wanted to use the PushApplication interface instead of leaving my app running in the background. I studied a lot the example app that comes with the push sdk but i am not sure of how to make use of it.
In my app i want to raise a notification when push arrives and then the user will open the app as usual from the menu and care about new info.
In the example the main doesn't care of how the app was launched(not uses entry points) so how do i know if i have to launch the ui or not(if the app was called by the push api)? In the example the main gets an uiapplication from pushlib that implements the pushapplication interface so receives the onmessage but i expected the main to handle this event....and then decide to launch or not the ui.. how does the api know that has to pass the pushstream to my uiapplication ? that is even not the same class as the one in which there is the main?
I'm a bit confused...please help me , thanks.
04-09-2011 07:41 AM
using OS 5 PushApplication API you can simply test at startup
isForeground()
if the app was started automatically by PushServices, then the app starts in background
----
if using OS 6 Communication API this is different: if app was autostarted from Push Receiver it's started in foreground.
04-09-2011 06:50 PM
Ok thanks, so the api starts my app in the main or in the onmessage function, this is what i can't understand.... because if it starts it in the onmessage method, i know that i've been waked by the api.... sorry if i ask but as most of us i'm still waiting for my push activation and my team cannot stop working and go on holiday just because we have to wait ages for a push service login ![]()
04-10-2011 03:13 AM
your App will always be started from main()
but if your App was started from Push Services, then you can ask ifForeground()
using OS 5 Push API it's false
(using OS 6 Communication API it's true, because - at the moment - 6.0 - Communication API starts always in foreground)
04-10-2011 09:29 AM - last edited on 04-10-2011 09:31 AM
So why should i implement the pushapplication interface? when is the api calling my onMessage? only when the app is already running?
the flow for a closed app that is waked because a push for it arrived is this?
API->appMain and stop? no onMessage? so i wonder how to read a push message without polling!
thanks
04-10-2011 09:33 AM
the PUSH API is calling onMessage() if a Push message comes in
but if the APP wasn't started, at first the APP must be started - and this will be done by Push Service automagically
04-10-2011 06:06 PM
ok thanks, now it's clear. So if my app is closed, in my main, i check for foreground(api 5.0) and then in any case i must istantate the class that implements PushApplication(maybe telling it someway that it doesn't have to push any screen on constructor? ) and then i call enterEventDispatcher on it.
Is that right? so in api 6 how can one understand if main was called by pushapi?
However if i have a thread that keeps running in a while, my app stays open? or there is a way to keep it pen even if there was no screen pushed?
Thanks a lot
04-11-2011 03:24 AM
your Application implements PushApplication
if your App is not running then Push Service will autostart your Application in Background
you can test ifForeground() and if false you know app was started by Push Service
in Background and will process onMessage()
if your Message-processing doesn't require UI then the App can still remain in Background to wait for more messages from Push Service or - if messages are rare you can exit the app after processing the messages
if App remains in Background and user later brings App to foreground you can detect this from
activate() <-- called if App comes from Back- to Foreground
and if activate() was called first time you can do your UI - dependend work
how your workflow looks like really depends from your logic what should happened after receiving messages
---
your question about OS 6 - Communication API:
you can still use OS 5 Network API under OS 6 - so if it's more comfortable for you if your app is in background, then use OS 5.
I'm working on some pure OS 6+ Apps where I try to use all OS 6 API .... still working on this ... let you know
04-26-2011 11:41 AM
Ok so i got my evaluation account and i can correctly subscribe the app when starts using the 5.0 push api, i also get the onStatusChanged callback function in my main class called and the status is "active".
However when i send a push to the device,the server response is 1001, the arrows in the upper right corner show but the onMessage callback function doesn't get called (nothing, i set a breakpoint ). Is there anything i could be missing? the app is the debug version but i don't think it's a problem, i also uninstalled and reinstalled but same behavior..
Thanks
04-26-2011 12:05 PM
if you query from your content server - is the device listed as "Active" ?