From 58ffb6fac8190158c88c5999ff31df5233380099 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 16 Apr 2014 10:51:50 +0200 Subject: [PATCH] Set/unset push info from contact uri param when setting changes --- src/org/linphone/LinphonePreferences.java | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/org/linphone/LinphonePreferences.java b/src/org/linphone/LinphonePreferences.java index 8283dcad3..d5db2e97c 100644 --- a/src/org/linphone/LinphonePreferences.java +++ b/src/org/linphone/LinphonePreferences.java @@ -775,6 +775,32 @@ public class LinphonePreferences { public void setPushNotificationEnabled(boolean enable) { getConfig().setBool("app", "push_notification", enable); + + if (enable) { + // Add push infos to exisiting proxy configs + String regId = getPushNotificationRegistrationID(); + String appId = getString(R.string.push_sender_id); + if (regId != null && getLc().getProxyConfigList().length > 0) { + for (LinphoneProxyConfig lpc : getLc().getProxyConfigList()) { + String contactInfos = "app-id=" + appId + ";pn-type=google;pn-tok=" + regId; + lpc.edit(); + lpc.setContactUriParameters(contactInfos); + lpc.done(); + Log.d("Push notif infos added to proxy config"); + } + getLc().refreshRegisters(); + } + } else { + if (getLc().getProxyConfigList().length > 0) { + for (LinphoneProxyConfig lpc : getLc().getProxyConfigList()) { + lpc.edit(); + lpc.setContactUriParameters(null); + lpc.done(); + Log.d("Push notif infos removed from proxy config"); + } + getLc().refreshRegisters(); + } + } } public boolean isPushNotificationEnabled() {