+\endcode
+<br> Note this operation has to be performed every time the application enters in background mode.
+<br> Anyway, for battery saving, UDP background mode is not recomnmanded
+<li><b>Entering bacground mode</b>
+<br> Before entering in background mode \code - (void)applicationDidEnterBackground:(UIApplication *)application \endcode The application must first refresh sip registration using function #linphone_core_refresh_registers();
+and register a Keep alive handler for periodically refreshing registration. The speudo code below show how to register a keep alive handler:
+\code
+ //First refresh registration
+ linphone_core_refresh_registers(theLinphoneCore);
+ //wait for registration answer
+ int i=0;
+ while (!linphone_proxy_config_is_registered(proxyCfg) && i++<40 ) {
+ linphone_core_iterate(theLinphoneCore);
+ usleep(100000);
+ }
+ //register keepalive handler
+ [[UIApplication sharedApplication] setKeepAliveTimeout:600/*minimal interval is 600 s*/
+ handler:^{
+ //refresh sip registration
+ linphone_core_refresh_registers(theLinphoneCore);
+ //make sure sip REGISTER
+ linphone_core_iterate(theLinphoneCore);
+ }];
+\endcode
+<li><b>Incoming call notification while in background mode</b>
+<br>Assuming application using liblinphone is well configured for multitasking, incoming calls arriving while liblinphone is in background mode will simply wakeup liblinphone thread but not resume GUI. To wakeup GUI, it is recommanded to send a Local Notification to the user from the #LinphoneCallStateCb. Here under a speudo code for this operation:
+\code
+ if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
+ // Create a new notification
+ UILocalNotification* notif = [[[UILocalNotification alloc] init] autorelease];
+ if (notif) {
+ notif.repeatInterval = 0;
+ notif.alertBody =@"New incoming call";
+ notif.alertAction = @"Answer";
+ notif.soundName = @"oldphone-mono-30s.caf";
+
+ [[UIApplication sharedApplication] presentLocalNotificationNow:notif];
+ }
+\endcode
+</ul>
+<b>Networking</b>
+<br>
+<ul><li><b>WWAN connection</b>
+<br>liblinphone relies on bsd socket for sip/rtp networking. On IOS, WWAN connection is supposed to automatically setup on any networking resquest issued by an application. At least on iPhone OS 3.x, BSD sockets do not automaticaly bring up the WWAN interface. So it is recommanded to add a special code to make sure the WWAN connection is properly setup. Speudo code belows describe a way to force WWAN connection.
+\code
+/*start a new thread to avoid blocking the main ui in case of peer host failure*/
+[NSThread detachNewThreadSelector:@selector(runNetworkConnection) toTarget:self withObject:nil];
+-(void) runNetworkConnection {
+ CFWriteStreamRef writeStream;
+ //create a dummy socket
+ CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"192.168.0.200", 15000, nil, &writeStream);
+ CFWriteStreamOpen (writeStream);
+ const char* buff="hello";
+ //try to write on this socket
+ CFWriteStreamWrite (writeStream,(const UInt8*)buff,strlen(buff));
+ CFWriteStreamClose (writeStream);
+}
+\endcode
+It is recommanded to perform this task each time the application is waked up, including keep alive handler.
+<li><b>Managing IP connection state</b>
+<br>liblinphone for IOS relies on the application to be informed of network changes. Network state change when the IP connection move from DOWN to UP, or from WIFI to WWAN. Applications using liblinphone must inform libliblinphone of this changes using function #linphone_core_set_network_reachable(). Usually this method is called from the IOS NetworkReachability callback. Here under a sample code:
+\code
+//typical reachability callback
+void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void * info) {
+ if ((flags == 0) | (flags & (kSCNetworkReachabilityFlagsConnectionRequired |kSCNetworkReachabilityFlagsConnectionOnTraffic))) {
+ //network state is off
+ linphone_core_set_network_reachable(lc,false);
+ ((LinphoneManager*)info).connectivity = none;
+ } else {
+ Connectivity newConnectivity = flags & kSCNetworkReachabilityFlagsIsWWAN ? wwan:wifi;
+ if (lLinphoneMgr.connectivity == none) {
+ //notify new network state
+ linphone_core_set_network_reachable(lc,true);
+ } else if (lLinphoneMgr.connectivity != newConnectivity) {
+ // connectivity has changed
+ linphone_core_set_network_reachable(lc,false);
+ linphone_core_set_network_reachable(lc,true);
+ }
+ //store new connectivity status
+ lLinphoneMgr.connectivity=newConnectivity;
+ }
+}
+}
+
+\endcode
+</ul>
+<b>DTMF feebacks</b>
+<br>liblinphone provides functions \link #linphone_core_play_dtmf() to play dtmf \endlink . Usually this is used to play a sound when the a user type a digit. On IOS, libLinphone relies on Audio unit for interfacing with the audio system. Audio unit initialization is a quit long operation that may trigger a bad user experience if performed each time a DTMF is played. On IOS, liblinphone introduce 2 functions for \link linphone_core_start_dtmf_stream() preloading \endlink \link #linphone_core_start_dtmf_stream() unloading \endlink underlying audio graph responsible of playing DTMFs.
+<br> For application using function #linphone_core_play_dtmf() , it is recommanded to call #linphone_core_start_dtmf_stream() when entering in foreground and #linphone_core_stop_dtmf_stream() upon entering background mode.
+*/