From 5fe9e65be67c29304081468b4e5e6a1abdddec4f Mon Sep 17 00:00:00 2001 From: Paul Cartier Date: Tue, 25 Feb 2020 09:42:59 +0100 Subject: [PATCH] Adding back the code to prevent unregister Removing this code requires an update of the sdk --- Classes/LinphoneAppDelegate.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index c8702338a..535c60bd4 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -320,6 +320,25 @@ 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]; }