HELP about background mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for your quick response..

I see what you are trying to get into but now I am lil bit confused about 
how apple implemented this background mode..

>From my understanding when Apple allowed (GPS, VOIP , AudioSessions) to run 
in the background, in our case if I want use a socket I can mark my App as 
VOIP then go an wrap my socket with kCFStreamNetworkServiceTypeVoIP... this 
will tell Apple to report back to me anything come to this socket even if my 
App is background.. so this is why I thought PJSIP did that wrapping for me 
so all the INVITES from asterisk to keep registration alive and the incoming 
calls will be passed to my App even if it is in background then I can use 
local notification message to let the user know..


Am I Wrong? or iOS background mode and PJSIP background mode are completely 
different?? I test a normal socket with background mode and it worked as I 
understand it from Apple documentations and I did not have to do any keep 
alive timer!!

Thank you again for you help and I really appreciate your support..

AsH

-----Original Message----- 
From: Michael Fortson
Sent: Wednesday, February 08, 2012 12:26 PM
To: pjsip list
Subject: Re: HELP about background mode

Sorry, missed that you were using Asterisk now. But the first issue to
address is getting multitasking working on its own, and verifying that
the app is waking up every 10 minutes to re-register.

One more quick note about Xcode and app suspend: you need to lock the
screen after hitting the home button, in order to fully suspend the
app.

In the application delegate, here's how the sample app registers the
10 minute callback:

#define KEEP_ALIVE_INTERVAL 600


- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [app performSelectorOnMainThread:@selector(keepAlive)
withObject:nil waitUntilDone:YES];
    [application setKeepAliveTimeout:KEEP_ALIVE_INTERVAL handler: ^{
    [app performSelectorOnMainThread:@selector(keepAlive)
withObject:nil waitUntilDone:YES];
    }];
}


- (void)keepAlive {

    NSlog(@"WAKE from sleep called");

    if (!pj_thread_is_registered())
    {
    pj_thread_register("ipjsua", a_thread_desc, &a_thread);
    }
    pjsua_acc_set_registration(0, PJ_TRUE); //actually sends the
registration update
}


So the main tasks, in order, are:
- make sure the app is suspending
- make sure the app is waking up to re-register every 10 minutes

And then:

- make sure the sip socket is receiving calls while in the background,
and that iOS is waking up the app when this happens






On Wed, Feb 8, 2012 at 7:28 AM, Ashraf Jaddo <ash.x.ash at hotmail.com> wrote:
> Hello,
>
>
> I am using PJSIP 1.12.. I did not run any special config when I compiled 
> the
> libraries.. just compile for ARM6 and ARM7 then merge.. I am trying to get
> background working so:
>
>
> - I used TCP instead of UDP as my protocol.
>
> - I checked PJ_ACTIVESOCK_TCP_IPHONE_OS_BG and
> PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT in OS_autu.h and I see both of the
> defined as 1. I see both of them defined in a ?#if defined(PJ_DARWINOS) &&
> PJ_DARWINOS!=0? so I did not change anything...
>
> - I added Required Background mode flag into my test App plist file
>
> When I launch my app from xcode by hitting the run button, then I press 
> home
> on the device to put the app in background mode I see logs from my
> registration function every 60 seconds as expected. and when I call the
> device I hit the on_incomming_call event as expected....
>
> But when I launch the app from the device itself just click on its icon 
> the
> background does not work..
>
> if I tried to call the device after 60 seconds, Astersik will say the 
> device
> is not registered which mean the background socket did not respond to the
> Keep alive message between the server and the device..if I removed the 
> plist
> entry about background mode It does not work in both cases (launch from
> xcode and launch from device), so I think I am on the right path...
>
>
> To confirm that my settings are good i added log success to ?static void
> activesock_create_iphone_os_stream(pj_activesock_t *asock)? when it set
> kCFStreamNetworkServiceTypeVoIP and I see that log when I start the app 
> from
> xcode but again I know it is working from xcode but not as a stand alone..
>
>
> Am I missing something else?? I have been researching this issue an I am 
> not
> sure what is missing? Anyone who did get background mode to work ??
>
>
> Thanks,,,,,
>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>

_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip at lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org 




[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux