forked from mirrors/linphone-iphone
update push notification parameters
- remove set_network_reachable: sdk will not register if push are allowed - uses push_notification_allowed instead of refkey in proxy config
This commit is contained in:
parent
01d40be896
commit
d1fc3684ef
6 changed files with 25 additions and 35 deletions
|
|
@ -320,25 +320,6 @@
|
|||
LOGI(@"%@", NSStringFromSelector(_cmd));
|
||||
LinphoneManager.instance.conf = TRUE;
|
||||
linphone_core_terminate_all_calls(LC);
|
||||
|
||||
// !!! Will be removed after push notification job finished
|
||||
// destroyLinphoneCore automatically unregister proxies but if we are using
|
||||
// remote push notifications, we want to continue receiving them
|
||||
if (LinphoneManager.instance.pushNotificationToken != nil) {
|
||||
// trick me! setting network reachable to false will avoid sending unregister
|
||||
const MSList *proxies = linphone_core_get_proxy_config_list(LC);
|
||||
BOOL pushNotifEnabled = NO;
|
||||
while (proxies) {
|
||||
const char *refkey = linphone_proxy_config_get_ref_key(proxies->data);
|
||||
pushNotifEnabled = pushNotifEnabled || (refkey && strcmp(refkey, "push_notification") == 0);
|
||||
proxies = proxies->next;
|
||||
}
|
||||
// but we only want to hack if at least one proxy config uses remote push..
|
||||
if (pushNotifEnabled) {
|
||||
linphone_core_set_network_reachable(LC, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
[LinphoneManager.instance destroyLinphoneCore];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -175,11 +175,9 @@
|
|||
proxy = proxies->data;
|
||||
// root section
|
||||
{
|
||||
const char *refkey = linphone_proxy_config_get_ref_key(proxy);
|
||||
if (refkey) {
|
||||
BOOL pushEnabled = (strcmp(refkey, "push_notification") == 0);
|
||||
BOOL pushEnabled = linphone_proxy_config_is_push_notification_allowed(proxy);
|
||||
[self setBool:pushEnabled forKey:@"account_pushnotification_preference"];
|
||||
}
|
||||
|
||||
const LinphoneAddress *identity_addr = linphone_proxy_config_get_identity_address(proxy);
|
||||
const char *server_addr = linphone_proxy_config_get_server_addr(proxy);
|
||||
LinphoneAddress *proxy_addr = linphone_core_interpret_url(LC, server_addr);
|
||||
|
|
@ -584,7 +582,7 @@
|
|||
}
|
||||
|
||||
// use empty string "" instead of NULL to avoid being overwritten by default proxy config values
|
||||
linphone_proxy_config_set_ref_key(proxyCfg, pushnotification ? "push_notification" : "no_push_notification");
|
||||
linphone_proxy_config_set_push_notification_allowed(proxyCfg, pushnotification);
|
||||
[LinphoneManager.instance configurePushTokenForProxyConfig:proxyCfg];
|
||||
|
||||
linphone_proxy_config_enable_register(proxyCfg, is_enabled);
|
||||
|
|
|
|||
|
|
@ -449,6 +449,22 @@ static int check_should_migrate_images(void *data, int argc, char **argv, char *
|
|||
}
|
||||
[self lpConfigSetBool:TRUE forKey:@"lime_migration_done"];
|
||||
}
|
||||
|
||||
if ([self lpConfigBoolForKey:@"push_notification_migration_done"] == FALSE) {
|
||||
const MSList *proxies = linphone_core_get_proxy_config_list(LC);
|
||||
bool_t pushEnabled;
|
||||
while (proxies) {
|
||||
const char *refkey = linphone_proxy_config_get_ref_key(proxies->data);
|
||||
if (refkey) {
|
||||
pushEnabled = (strcmp(refkey, "push_notification") == 0);
|
||||
} else {
|
||||
pushEnabled = true;
|
||||
}
|
||||
linphone_proxy_config_set_push_notification_allowed(proxies->data, pushEnabled);
|
||||
proxies = proxies->next;
|
||||
}
|
||||
[self lpConfigSetBool:TRUE forKey:@"push_notification_migration_done"];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)migrationPerAccount {
|
||||
|
|
@ -473,7 +489,7 @@ static int check_should_migrate_images(void *data, int argc, char **argv, char *
|
|||
[self lpConfigSetBool:NO forKey:@"pushnotification_preference"];
|
||||
const MSList *proxies = linphone_core_get_proxy_config_list(LC);
|
||||
while (proxies) {
|
||||
linphone_proxy_config_set_ref_key(proxies->data, "push_notification");
|
||||
linphone_proxy_config_set_push_notification_allowed(proxies->data, true);
|
||||
[self configurePushTokenForProxyConfig:proxies->data];
|
||||
proxies = proxies->next;
|
||||
}
|
||||
|
|
@ -2078,8 +2094,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
|
||||
// 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);
|
||||
BOOL pushNotifEnabled = linphone_proxy_config_is_push_notification_allowed(proxyCfg);
|
||||
if ([LinphoneManager.instance lpConfigBoolForKey:@"backgroundmode_preference"] || pushNotifEnabled) {
|
||||
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
|
||||
// For registration register
|
||||
|
|
@ -2133,8 +2148,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
|
||||
LOGI(@"Entering [%s] bg mode", shouldEnterBgMode ? "normal" : "lite");
|
||||
if (!shouldEnterBgMode && floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
|
||||
const char *refkey = proxyCfg ? linphone_proxy_config_get_ref_key(proxyCfg) : NULL;
|
||||
BOOL pushNotifEnabled = (refkey && strcmp(refkey, "push_notification") == 0);
|
||||
BOOL pushNotifEnabled = linphone_proxy_config_is_push_notification_allowed(proxyCfg);
|
||||
if (pushNotifEnabled) {
|
||||
LOGI(@"Keeping lc core to handle push");
|
||||
return YES;
|
||||
|
|
@ -2529,8 +2543,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
linphone_proxy_config_edit(proxyCfg);
|
||||
|
||||
NSData *tokenData = _pushNotificationToken;
|
||||
const char *refkey = linphone_proxy_config_get_ref_key(proxyCfg);
|
||||
BOOL pushNotifEnabled = (refkey && strcmp(refkey, "push_notification") == 0);
|
||||
BOOL pushNotifEnabled = linphone_proxy_config_is_push_notification_allowed(proxyCfg);
|
||||
if (tokenData != nil && pushNotifEnabled) {
|
||||
const unsigned char *tokenBuffer = [tokenData bytes];
|
||||
NSMutableString *tokenString = [NSMutableString stringWithCapacity:[tokenData length] * 2];
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
<entry name="reg_identity" overwrite="true">sip:?@sip.linphone.org</entry>
|
||||
<entry name="reg_proxy" overwrite="true"><sip:sip.linphone.org;transport=tls></entry>
|
||||
<entry name="reg_sendregister" overwrite="true">1</entry>
|
||||
<entry name="refkey" overwrite="true">push_notification</entry>
|
||||
<entry name="realm" overwrite="true">sip.linphone.org</entry>
|
||||
<entry name="nat_policy_ref" overwrite="true">nat_policy_default_values</entry>
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
<entry name="reg_identity" overwrite="true">sip:?@sip.linphone.org</entry>
|
||||
<entry name="reg_proxy" overwrite="true"><sip:sip.linphone.org;transport=tls></entry>
|
||||
<entry name="reg_sendregister" overwrite="true">1</entry>
|
||||
<entry name="refkey" overwrite="true">push_notification</entry>
|
||||
<entry name="realm" overwrite="true">sip.linphone.org</entry>
|
||||
<entry name="nat_policy_ref" overwrite="true">nat_policy_default_values</entry>
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@
|
|||
linphone_proxy_config_set_identity_address(testProxy, testAddr);
|
||||
linphone_proxy_config_set_server_addr(testProxy, [self accountProxyRoute].UTF8String);
|
||||
linphone_proxy_config_set_route(testProxy, [self accountProxyRoute].UTF8String);
|
||||
linphone_proxy_config_set_ref_key(testProxy, "push_notification");
|
||||
linphone_proxy_config_set_push_notification_allowed(testProxy, true);
|
||||
|
||||
LinphoneAuthInfo *testAuth = linphone_auth_info_new(linphone_address_get_username(testAddr), NULL,
|
||||
linphone_address_get_username(testAddr), NULL, NULL,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue