diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index f31d5aa5d..72528de11 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -128,6 +128,7 @@ static UICompositeViewDescription *compositeDescription = nil; [_pictureButton setEnabled:fileSharingEnabled]; [self callUpdateEvent:nil]; + PhoneMainView.instance.currentRoom = self.chatRoom; } - (void)viewWillDisappear:(BOOL)animated { @@ -138,6 +139,7 @@ static UICompositeViewDescription *compositeDescription = nil; [self setComposingVisible:FALSE withDelay:0]; // will hide the "user is composing.." message [NSNotificationCenter.defaultCenter removeObserver:self]; + PhoneMainView.instance.currentRoom = NULL; } - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index cbdd9329d..09155756c 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -201,25 +201,6 @@ - (void)registerForNotifications:(UIApplication *)app { LinphoneManager *instance = [LinphoneManager instance]; - /*if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) { - // Set up for UserNotifications framework - UNNotificationAction* act_ans = [UNNotificationAction actionWithIdentifier:@"Answer" title:@"Answer" options:UNNotificationActionOptionNone]; - UNNotificationAction* act_dec = [UNNotificationAction actionWithIdentifier:@"Decline" title:@"Decline" options:UNNotificationActionOptionNone]; - UNNotificationCategory* cat_call = [UNNotificationCategory categoryWithIdentifier:@"call_cat" actions:[NSArray arrayWithObjects:act_ans, act_dec, nil] intentIdentifiers:[[NSMutableArray alloc] init] options:UNNotificationCategoryOptionCustomDismissAction]; - - //UNUserNotificationCenter* notifCenter = [UNUserNotificationCenter currentNotificationCenter]; - [UNUserNotificationCenter currentNotificationCenter].delegate = self; - [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge) - completionHandler:^(BOOL granted, NSError * _Nullable error) { - // Enable or disable features based on authorization. - if (error) { - LOGD(error.description); - } - }]; - NSSet* categories = [NSSet setWithObjects:cat_call, nil]; - [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:categories]; - }*/ - if (floor(NSFoundationVersionNumber) >= NSFoundationVersionNumber_iOS_8_0) { //[app unregisterForRemoteNotifications]; // iOS8 and more : PushKit @@ -391,9 +372,7 @@ LOGE(@"PushNotification: does not have call-id yet, fix it !"); } - if ([loc_key isEqualToString:@"IM_MSG"] || [loc_key isEqualToString:@"IM_FULLMSG"]) { - [PhoneMainView.instance changeCurrentView:ChatsListView.compositeViewDescription]; - } else if ([loc_key isEqualToString:@"IC_MSG"]) { + if ([loc_key isEqualToString:@"IC_MSG"]) { [self fixRing]; } } @@ -553,6 +532,11 @@ didInvalidatePushTokenForType:(NSString *)type { #pragma mark - UserNotifications Framework +- (void) userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler { + completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionAlert); +} + + - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler { diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index e6e4376a5..ad1d62f4a 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1127,7 +1127,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char NSString *remote_uri = [NSString stringWithUTF8String:c_address]; ms_free(c_address); - if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { + if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || ((PhoneMainView.instance.currentView != ChatsListView.compositeViewDescription) && ((PhoneMainView.instance.currentView != ChatConversationView.compositeViewDescription))) || (PhoneMainView.instance.currentView == ChatConversationView.compositeViewDescription && room != PhoneMainView.instance.currentRoom)) { // Create a new notification if(floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { @@ -1204,7 +1204,6 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char } else { content.body = from; } - content.sound = [UNNotificationSound soundNamed:@"msg.caf"]; content.categoryIdentifier = @"msg_cat"; content.userInfo = @{ @"from" : from, @"from_addr" : remote_uri, @"call-id" : callID }; diff --git a/Classes/PhoneMainView.h b/Classes/PhoneMainView.h index 6d3538ee5..d7d7f1218 100644 --- a/Classes/PhoneMainView.h +++ b/Classes/PhoneMainView.h @@ -80,6 +80,7 @@ @property(nonatomic, strong) NSString *name; @property(weak, readonly) UICompositeViewDescription *currentView; +@property LinphoneChatRoom* currentRoom; @property(readonly, strong) MPVolumeView *volumeView; - (void)changeCurrentView:(UICompositeViewDescription *)view; diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index 812e5c7e1..8e124b932 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -126,6 +126,7 @@ static RootViewManager *rootViewManagerInstance = nil; - (void)initPhoneMainView { currentView = nil; + _currentRoom = NULL; inhibitedEvents = [[NSMutableArray alloc] init]; }