diff --git a/Classes/HistoryViewController.m b/Classes/HistoryViewController.m index 92cb769b3..30ec0ffc6 100644 --- a/Classes/HistoryViewController.m +++ b/Classes/HistoryViewController.m @@ -81,6 +81,11 @@ static UICompositeViewDescription *compositeDescription = nil; [editButton setOff]; [self changeView: History_All]; [self.tableView reloadData]; + + // Reset missed call + linphone_core_reset_missed_calls_count([LinphoneManager getLc]); + // Fake event + [[NSNotificationCenter defaultCenter] postNotificationName:@"LinphoneCallUpdate" object:self]; } - (void)viewDidLoad { diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 58a6a2356..ec89ddc2d 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -165,6 +165,7 @@ int __aeabi_idiv(int a, int b) { } - (void)setupUI { + [[PhoneMainView instance] startUp]; if ([[LinphoneManager instance].settingsStore boolForKey:@"enable_first_login_view_preference"] == true) { // Change to fist login view [[PhoneMainView instance] changeCurrentView: [FirstLoginViewController compositeViewDescription]]; diff --git a/Classes/LinphoneUI/UIMainBar.m b/Classes/LinphoneUI/UIMainBar.m index ec2b88989..4c5fba903 100644 --- a/Classes/LinphoneUI/UIMainBar.m +++ b/Classes/LinphoneUI/UIMainBar.m @@ -258,13 +258,7 @@ [target.layer removeAnimationForKey:animationID]; } -- (void)updateView:(UICompositeViewDescription*) view { - // Reset missed call - if([view equal:[HistoryViewController compositeViewDescription]]) { - linphone_core_reset_missed_calls_count([LinphoneManager getLc]); - [self updateMissedCall:0 appear:FALSE]; - } - +- (void)updateView:(UICompositeViewDescription*) view { // Update buttons if([view equal:[HistoryViewController compositeViewDescription]]) { historyButton.selected = TRUE; diff --git a/Classes/PhoneMainView.h b/Classes/PhoneMainView.h index 038db2155..6514290d0 100644 --- a/Classes/PhoneMainView.h +++ b/Classes/PhoneMainView.h @@ -60,6 +60,8 @@ - (void)showStateBar:(BOOL)show; - (void)showTabBar:(BOOL)show; - (void)fullScreen:(BOOL)enabled; +- (void)startUp; + + (void)forceOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated; + (PhoneMainView*) instance; diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index 9fc5479af..3b49f4320 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -114,7 +114,7 @@ static PhoneMainView* phoneMainViewInstance=nil; object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(batteryLevelChanged:) - name:UIDeviceBatteryLevelDidChangeNotification + name:UIDeviceBatteryLevelDidChangeNotification object:nil]; } @@ -242,6 +242,7 @@ static PhoneMainView* phoneMainViewInstance=nil; ChatModel *chat = [[notif userInfo] objectForKey:@"chat"]; if(chat != nil) { [self displayMessage:chat]; + [self updateApplicationBadgeNumber]; } } @@ -340,11 +341,23 @@ static PhoneMainView* phoneMainViewInstance=nil; default: break; } + [self updateApplicationBadgeNumber]; } #pragma mark - +- (void)startUp { + [self updateApplicationBadgeNumber]; // Update Badge at startup +} + +- (void)updateApplicationBadgeNumber { + int count = 0; + count += linphone_core_get_missed_calls_count([LinphoneManager getLc]); + count += [ChatModel unreadMessages]; + [[UIApplication sharedApplication] setApplicationIconBadgeNumber:count]; +} + + (CATransition*)getBackwardTransition { CATransition* trans = [CATransition animation]; [trans setType:kCATransitionPush];