Fix push notification token handling: we systematically added it even though sometimes it wasn't needed/wanted

This commit is contained in:
Guillaume BIENKOWSKI 2014-12-08 12:32:44 +01:00
parent 2d621853d9
commit cb95b395af
4 changed files with 13 additions and 10 deletions

View file

@ -413,7 +413,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
}
lp_config_set_int(conf, LINPHONERC_APPLICATION_KEY, "pushnotification_preference", pushnotification);
if( pushnotification ) [[LinphoneManager instance] addPushTokenToProxyConfig:proxyCfg];
[[LinphoneManager instance] configurePushTokenForProxyConfig:proxyCfg];
linphone_proxy_config_enable_register(proxyCfg, true);
linphone_proxy_config_enable_avpf(proxyCfg, use_avpf);

View file

@ -138,7 +138,7 @@ typedef struct _LinphoneManagerSounds {
- (void)becomeActive;
- (BOOL)enterBackgroundMode;
- (void)enableAutoAnswerForCallId:(NSString*) callid;
- (void)addPushTokenToProxyConfig: (LinphoneProxyConfig*)cfg;
- (void)configurePushTokenForProxyConfig: (LinphoneProxyConfig*)cfg;
- (BOOL)shouldAutoAcceptCallForCallId:(NSString*) callId;
- (void)acceptCallForCallId:(NSString*)callid;
- (void)cancelLocalNotifTimerForCallId:(NSString*)callid;

View file

@ -1946,14 +1946,14 @@ static void audioRouteChangeListenerCallback (
}
LinphoneProxyConfig *cfg=nil;
linphone_core_get_default_proxy(theLinphoneCore, &cfg);
if (cfg) {
if (cfg ) {
linphone_proxy_config_edit(cfg);
[self addPushTokenToProxyConfig: cfg];
[self configurePushTokenForProxyConfig: cfg];
linphone_proxy_config_done(cfg);
}
}
- (void)addPushTokenToProxyConfig:(LinphoneProxyConfig*)proxyCfg{
- (void)configurePushTokenForProxyConfig:(LinphoneProxyConfig*)proxyCfg{
NSData *tokenData = pushNotificationToken;
if(tokenData != nil && [self lpConfigBoolForKey:@"pushnotification_preference"]) {
const unsigned char *tokenBuffer = [tokenData bytes];
@ -1972,10 +1972,15 @@ static void audioRouteChangeListenerCallback (
linphone_proxy_config_set_contact_uri_parameters(proxyCfg, [params UTF8String]);
linphone_proxy_config_set_contact_parameters(proxyCfg, NULL);
}
} else {
// no push token:
linphone_proxy_config_set_contact_uri_parameters(proxyCfg, NULL);
linphone_proxy_config_set_contact_parameters(proxyCfg, NULL);
}
}
#pragma mark - Misc Functions
+ (NSString*)bundleFile:(NSString*)file {

View file

@ -418,10 +418,8 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)setDefaultSettings:(LinphoneProxyConfig*)proxyCfg {
LinphoneManager* lm = [LinphoneManager instance];
BOOL pushnotification = [lm lpConfigBoolForKey:@"pushnotification_preference"];
if(pushnotification) {
[lm addPushTokenToProxyConfig:proxyCfg];
}
[lm configurePushTokenForProxyConfig:proxyCfg];
}
- (void)addProxyConfig:(NSString*)username password:(NSString*)password domain:(NSString*)domain {