Untitled

 avatar
unknown
plain_text
5 months ago
8.2 kB
2
Indexable
{
    [Utility getNotificationTabCountAPI];
    
    NSLog(@"%@", notification.request.content.userInfo);
    
    NSDictionary *dictNotification = notification.request.content.userInfo;
    
    NSString *identifier = [dictNotification objectForKey:@"notification_id"];
    BOOL isIdentifierPresent = [Utility checkNotificationIdentifier:identifier];
    if (!isIdentifierPresent) {
    PushNotificationModel *model = [[PushNotificationModel alloc] init];
    
    model.strNotificationTitle = CHECK_NULL_STRING([[[dictNotification objectForKey:@"aps"] objectForKey:@"alert"] objectForKey:@"title"]);
    model.strNotificationBody  = CHECK_NULL_STRING([[[dictNotification objectForKey:@"aps"] objectForKey:@"alert"] objectForKey:@"body"]);
    model.strMessageType       = CHECK_NULL_STRING([dictNotification objectForKey:@"msg_type"]);
    model.groupID              = CHECK_NULL_STRING([dictNotification objectForKey:@"group_id"]);
    model.strMessageId         = CHECK_NULL_STRING([dictNotification objectForKey:@"msg_id"]);
    model.strNotificationId    = CHECK_NULL_STRING([dictNotification objectForKey:@"notification_id"]);
    model.group_description    = CHECK_NULL_STRING([dictNotification objectForKey:@"group_description"]);
    model.group_img            = CHECK_NULL_STRING([dictNotification objectForKey:@"group_img"]);
    model.group_name           = CHECK_NULL_STRING([dictNotification objectForKey:@"group_name"]);
    model.strSubId             = CHECK_NULL_STRING([dictNotification objectForKey:@"sub_id"]);
    model.exhi_page_id         = CHECK_NULL_STRING([dictNotification objectForKey:@"exhi_page_id"]);
    model.str_image            = CHECK_NULL_STRING([dictNotification objectForKey:@"image"]);
    model.str_url              = CHECK_NULL_STRING([dictNotification objectForKey:@"url"]);
    model.attendeeDesignation  = CHECK_NULL_STRING([dictNotification objectForKey:@"Designation"]);
    model.attendeeFirstname    = CHECK_NULL_STRING([dictNotification objectForKey:@"Firstname"]);
    model.attendeeLastname     = CHECK_NULL_STRING([dictNotification objectForKey:@"Lastname"]);
    model.attendeeCompany      = CHECK_NULL_STRING([dictNotification objectForKey:@"company"]);
    model.attendeeMessage_id   = CHECK_NULL_STRING([dictNotification objectForKey:@"message_id"]);
    model.channel_id           = CHECK_NULL_STRING([dictNotification objectForKey:@"channel_id"]);
    model.user_id              = CHECK_NULL_STRING([dictNotification objectForKey:@"user_id"]);
    model.type                 = CHECK_NULL_STRING([dictNotification objectForKey:@"type"]);
    model.agenda_id            = CHECK_NULL_STRING([dictNotification objectForKey:@"agenda_id"]);
    model.broadcaster_id       = CHECK_NULL_STRING([dictNotification objectForKey:@"broadcaster_id"]);
    model.uid                  = CHECK_NULL_STRING([dictNotification objectForKey:@"uid"]);
    model.is_live              = CHECK_NULL_STRING([dictNotification objectForKey:@"is_live"]);
    model.is_preview           = CHECK_NULL_STRING([dictNotification objectForKey:@"is_preview"]);
    model.is_video_link        = CHECK_NULL_STRING([dictNotification objectForKey:@"is_video_link"]);
    model.attendee_id        = CHECK_NULL_STRING([dictNotification objectForKey:@"attendee_id"]);
    
    if([UIApplication sharedApplication].applicationState != UIApplicationStateActive){
        [self callNotificationLogAPI:model withOpenStatus:NO];
    }
    
    if ([model.strMessageType isEqual: kNotificationGroup] ||
        [model.strMessageType isEqual: kNotificationAddGroup] ||
        [model.strMessageType isEqual: kNotificationExitGroup] ||
        [model.strMessageType isEqual: kNotificationEditGroup] ||
        [model.strMessageType isEqual: kNotificationDeleteGroup]) {
        
        if(GetBoolForKey(IS_LOGIN)) {
            [Utility getNotificationTabCountAPI];
        }
        if ([[Utility getCurrectViewController] isKindOfClass: [NotificationMessageVC class]]) {
            NotificationMessageVC *vc = (NotificationMessageVC *)[Utility getCurrectViewController];
            [vc messageNotificationAPI];
        }
        
        if ([[Utility getCurrectViewController] isKindOfClass: [PrivateMessageDetailVC class]]) {
            PrivateMessageDetailVC *vc = (PrivateMessageDetailVC *)[Utility getCurrectViewController];
            if ([model.groupID isEqualToString: vc.model.group_id]) {
                [[NSNotificationCenter defaultCenter] postNotificationName:kNCReloadGroupDetail object:nil userInfo:nil];
            }
            else {
                [[NSNotificationCenter defaultCenter] postNotificationName:kNCReloadGroupList object:nil userInfo:nil];
                completionHandler(UNNotificationPresentationOptionAlert);
            }
        } else {
            [[NSNotificationCenter defaultCenter] postNotificationName:kNCReloadGroupList object:nil userInfo:nil];
            completionHandler(UNNotificationPresentationOptionAlert);
        }
    }else if ([model.strMessageType isEqual: kNotificationPrivate]){
        if(GetBoolForKey(IS_LOGIN)) {
            [Utility getNotificationTabCountAPI];
        }
        if ([[Utility getCurrectViewController] isKindOfClass: [NotificationMessageVC class]]) {
            NotificationMessageVC *vc = (NotificationMessageVC *)[Utility getCurrectViewController];
            [vc messageNotificationAPI];
        }
        if ([[Utility getCurrectViewController] isKindOfClass: [PrivateMessageDetailVC class]]) {
            PrivateMessageDetailVC *vc = (PrivateMessageDetailVC *)[Utility getCurrectViewController];
            if ([model.strMessageId isEqualToString: vc.senderDetailModel.senderId]) {
                [[NSNotificationCenter defaultCenter] postNotificationName:kNCReloadMessageDetail object:nil userInfo:nil];
            }else{
                completionHandler(UNNotificationPresentationOptionAlert);
            }
        }else{
            completionHandler(UNNotificationPresentationOptionAlert);
        }
    }
    else if ([model.strMessageType isEqualToString:kNotificationExhiVideoCall]) {
        completionHandler(UNNotificationPresentationOptionSound);
    }
    else if ([model.strMessageType isEqual: kNotificationVirtualMeetingRequest]) {
        if ([[Utility getCurrectViewController] isKindOfClass: [RoomViewController class]]) {
            //            MyMeetingsListVC *vc = (MyMeetingsListVC *)[Utility getCurrectViewController];
            //            if ([model.strMessageId isEqualToString: vc.senderDetailModel.senderId]) {
            //                [[NSNotificationCenter defaultCenter] postNotificationName:kNCReloadMessageDetail object:nil userInfo:nil];
            //            }else{
            //                completionHandler(UNNotificationPresentationOptionAlert);
            //            }
            completionHandler(UNNotificationPresentationOptionSound);
        }
        else{
            completionHandler(UNNotificationPresentationOptionSound);
        }
        if ([[Utility getCurrectViewController] isKindOfClass: [RoomViewController class]]) {
            //            MyMeetingsListVC *vc = (MyMeetingsListVC *)[Utility getCurrectViewController];
            //            if ([model.strMessageId isEqualToString: vc.senderDetailModel.senderId]) {
            //                [[NSNotificationCenter defaultCenter] postNotificationName:kNCReloadMessageDetail object:nil userInfo:nil];
            //            }else{
            //                completionHandler(UNNotificationPresentationOptionAlert);
            //            }
            completionHandler(UNNotificationPresentationOptionSound);
        }
        else{
            completionHandler(UNNotificationPresentationOptionSound);
        }
    }
    else if ([model.strMessageType isEqual: kNotificationModeratorBroadcasting]) {
        completionHandler(UNNotificationPresentationOptionNone);
    }
    else if([model.strMessageType isEqualToString: kNotificationAvailabelUser]) {
        completionHandler(UNNotificationPresentationOptionNone);
    }
    
    [self setUpExtraNotificationKeys:notification.request.content.userInfo withAppInForegroundStatus:YES];
}
}
Editor is loading...
Leave a Comment