IOS10 network down when in background & send timeout for pushnotification

This commit is contained in:
REIS Benjamin 2016-09-16 13:59:16 +02:00
parent 53add0efe2
commit ae20b0dd8e
2 changed files with 33 additions and 7 deletions

View file

@ -50,6 +50,10 @@
- (void)applicationDidEnterBackground:(UIApplication *)application {
LOGI(@"%@", NSStringFromSelector(_cmd));
if (floor(NSFoundationVersionNumber) >= NSFoundationVersionNumber_iOS_9_x_Max && (linphone_core_get_calls_nb(LC) == 0)) {
linphone_core_set_network_reachable(LC, FALSE);
LinphoneManager.instance.connectivity = none;
}
[LinphoneManager.instance enterBackgroundMode];
}
@ -329,11 +333,11 @@
/*if we receive a remote notification, it is probably because our TCP background socket was no more working.
As a result, break it and refresh registers in order to make sure to receive incoming INVITE or MESSAGE*/
if (linphone_core_get_calls(LC) == NULL) { // if there are calls, obviously our TCP socket shall be working
linphone_core_set_network_reachable(LC, FALSE);
LinphoneManager.instance.connectivity = none; /*force connectivity to be discovered again*/
LOGI(@"Registers refreshing");
[LinphoneManager.instance refreshRegisters];
LOGI(@"Registers refreshed");
//linphone_core_set_network_reachable(LC, FALSE);
if (!linphone_core_is_network_reachable(LC)) {
LinphoneManager.instance.connectivity = none; //Force connectivity to be discovered again
[LinphoneManager.instance setupNetworkReachabilityCallback];
}
if (loc_key != nil) {
NSString *callId = [userInfo objectForKey:@"call-id"];

View file

@ -704,6 +704,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char
}
}
//}
}
}
@ -723,6 +724,21 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char
_bluetoothEnabled = FALSE;
/*IOS specific*/
linphone_core_start_dtmf_stream(theLinphoneCore);
if (floor(NSFoundationVersionNumber) >= NSFoundationVersionNumber_iOS_9_x_Max && ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground)) {
linphone_core_set_network_reachable(LC, FALSE);
LinphoneManager.instance.connectivity = none;
LinphoneProxyConfig *proxyCfg = linphone_core_get_default_proxy_config(theLinphoneCore);
// handle proxy config if any
if (proxyCfg) {
const char *refkey = proxyCfg ? linphone_proxy_config_get_ref_key(proxyCfg) : NULL;
BOOL pushNotifEnabled = (refkey && strcmp(refkey, "push_notification") == 0);
if ([LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"] || pushNotifEnabled) {
// For registration register
[self refreshRegisters];
}
}
}
}
if (incallBgTask) {
[[UIApplication sharedApplication] endBackgroundTask:incallBgTask];
@ -2226,11 +2242,17 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
// IOS 7 and below
notif_type = @"";
}
NSString *timeout;
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) {
timeout = @";pn-timeout=0";
} else {
timeout = @"";
}
NSString *params = [NSString
stringWithFormat:@"app-id=%@%@.%@;pn-type=apple;pn-tok=%@;pn-msg-str=IM_MSG;pn-call-str=IC_MSG;pn-"
@"call-snd=%@;pn-msg-snd=msg.caf",
[[NSBundle mainBundle] bundleIdentifier], notif_type, APPMODE_SUFFIX, tokenString, ring];
@"call-snd=%@;pn-msg-snd=msg.caf%@",
[[NSBundle mainBundle] bundleIdentifier], notif_type, APPMODE_SUFFIX, tokenString, ring, timeout];
LOGI(@"Proxy config %s configured for push notifications with contact: %@",
linphone_proxy_config_get_identity(proxyCfg), params);