Try to start background task sooner

This commit is contained in:
Benjamin Reis 2018-01-04 14:46:15 +01:00
parent 7215bfcd49
commit 84695a8d0f
5 changed files with 42 additions and 35 deletions

View file

@ -430,10 +430,17 @@
return;
NSString *loc_key = [aps objectForKey:@"loc-key"];
NSString *callId = [aps objectForKey:@"call-id"];
if (!loc_key || !callId)
NSString *callId = [aps objectForKey:@"call-id"] ?: @"";
if (!loc_key)
return;
if ([self addLongTaskIDforCallID:callId] && [UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
if ([loc_key isEqualToString:@"IC_MSG"])
[LinphoneManager.instance startPushLongRunningTask:FALSE callId:callId];
else if ([loc_key isEqualToString:@"IM_MSG"])
[LinphoneManager.instance startPushLongRunningTask:TRUE callId:callId];
}
// 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_is_network_reachable(LC)) {
@ -441,14 +448,6 @@
[LinphoneManager.instance setupNetworkReachabilityCallback];
}
if ([self addLongTaskIDforCallID:callId] && [UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
if ([loc_key isEqualToString:@"IC_MSG"]) {
[LinphoneManager.instance startPushLongRunningTask:FALSE callId:callId];
[self fixRing];
} else if ([loc_key isEqualToString:@"IM_MSG"])
[LinphoneManager.instance startPushLongRunningTask:TRUE callId:callId];
}
if ([callId isEqualToString:@""]) {
//Present apn pusher notifications for info
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) {

View file

@ -2385,28 +2385,6 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
}
if ([LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"]) {
// register keepalive
if ([[UIApplication sharedApplication]
setKeepAliveTimeout:600 /*(NSTimeInterval)linphone_proxy_config_get_expires(proxyCfg)*/
handler:^{
LOGW(@"keepalive handler");
mLastKeepAliveDate = [NSDate date];
if (theLinphoneCore == nil) {
LOGW(@"It seems that Linphone BG mode was deactivated, just skipping");
return;
}
[_iapManager check];
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
// For registration register
[self refreshRegisters];
}
linphone_core_iterate(theLinphoneCore);
}]) {
LOGI(@"keepalive handler succesfully registered");
} else {
LOGI(@"keepalive handler cannot be registered");
}
shouldEnterBgMode = TRUE;
}
}

View file

@ -509,7 +509,7 @@ static RootViewManager *rootViewManagerInstance = nil;
- (void)startUp {
@try {
LinphoneManager *lm = LinphoneManager.instance;
LOGE(@"%s", linphone_global_state_to_string(
LOGI(@"%s", linphone_global_state_to_string(
linphone_core_get_global_state(LC)));
if (linphone_core_get_global_state(LC) != LinphoneGlobalOn) {
[self changeCurrentView:DialerView.compositeViewDescription];

View file

@ -24,7 +24,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.16.5</string>
<string>3.16.6</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
@ -53,7 +53,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>11</string>
<string>0</string>
<key>ITSAppUsesNonExemptEncryption</key>
<true/>
<key>ITSEncryptionExportComplianceCode</key>

View file

@ -828,6 +828,20 @@
remoteGlobalIDString = FAB8A0141CAC546A00C6DFC1;
remoteInfo = KIFFrameworkConsumerTests;
};
8C8686D41FFE675F0044501F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 630589F21B4E816900EFAE36 /* KIF.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 8CD87D4C1EF5105800ACA260;
remoteInfo = LinphoneManager;
};
8C8686D61FFE675F0044501F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 630589F21B4E816900EFAE36 /* KIF.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 8CD87D541EF5105900ACA260;
remoteInfo = LinphoneManagerTests;
};
F08F119119C09C6B007D70C2 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
@ -2306,6 +2320,8 @@
63058A071B4E816A00EFAE36 /* KIF.framework */,
633FC7C81CD7466400774B8B /* KIFFrameworkConsumer.app */,
633FC7CA1CD7466400774B8B /* KIFFrameworkConsumerTests.xctest */,
8C8686D51FFE675F0044501F /* LinphoneManager.framework */,
8C8686D71FFE675F0044501F /* LinphoneManagerTests.xctest */,
);
name = Products;
sourceTree = "<group>";
@ -3230,6 +3246,20 @@
remoteRef = 633FC7C91CD7466400774B8B /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
8C8686D51FFE675F0044501F /* LinphoneManager.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = LinphoneManager.framework;
remoteRef = 8C8686D41FFE675F0044501F /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
8C8686D71FFE675F0044501F /* LinphoneManagerTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = LinphoneManagerTests.xctest;
remoteRef = 8C8686D61FFE675F0044501F /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */