Untitled

 avatar
unknown
plain_text
6 months ago
14 kB
3
Indexable
-(void)setUpExtraNotificationKeys:(NSDictionary*)dictNotification withAppInForegroundStatus:(BOOL)isAppInForeground
{
//    [Utility getNotificationTabCountAPI];
    
    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.dateForNewMeeting    = CHECK_NULL_STRING([dictNotification objectForKey:@"meeting_date"]);
    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.agendaHeading        = CHECK_NULL_STRING([dictNotification objectForKey:@"Heading"]);
    model.agendaQAId           = CHECK_NULL_STRING([dictNotification objectForKey:@"agendaQAId"]);
    model.agendaPresentationId = CHECK_NULL_STRING([dictNotification objectForKey:@"agendaPresentationId"]);
    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.is_mute              = CHECK_NULL_STRING([dictNotification objectForKey:@"is_mute"]);
    model.meetingroom_full     = CHECK_NULL_STRING([dictNotification objectForKey:@"meetingroom_full"]);
    model.attendee_id          = CHECK_NULL_STRING([dictNotification objectForKey:@"attendee_id"]);
    model.hide_open_button     = CHECK_NULL_STRING([dictNotification objectForKey:@"hide_open_button"]);
    model.agenda_category_id   = CHECK_NULL_STRING([dictNotification objectForKey:@"agenda_category_id"]);
    model.agenda_session_id    = CHECK_NULL_STRING([dictNotification objectForKey:@"agenda_session_id"]);
    model.is_agenda_session     = CHECK_NULL_STRING([dictNotification objectForKey:@"is_agenda_session"]);
    if (![model.strMessageType isEqualToString:kNotificationUpdateGCMId]){
        [Utility getNotificationTabCountAPI];
    }
    if(isAppInForeground)
    {
        if ([model.strMessageType isEqualToString:kNotificationUpdateGCMId] ||
           [model.strMessageType isEqualToString:@"presentation"] ||
           [model.strMessageType isEqualToString:kNotificationQAQusetion] ||
           [model.strMessageType isEqualToString:kNotificationUpdateGeoNoti] ||
           [model.strMessageType isEqualToString:kNotificationEditGroup]||
           [model.strMessageType isEqualToString:kNotificationAddGroup]||
           [model.strMessageType isEqualToString:kNotificationExitGroup]||
           [model.strMessageType isEqualToString:kNotificationDeleteGroup] ||
           [model.strMessageType isEqualToString:kNotificationAgendaDetailComment] ||
           [model.strMessageType isEqualToString:kNotificationModeratorAgendaMeetingComment])
           
        {
            
        }
        else if ([model.strMessageType isEqualToString: kNotificationVirtualMeetingRequest]) {
            
        }
        else if ([model.strMessageType isEqualToString: kNotificationExhiCallingStatus]) {
            
            UIApplicationState state = [[UIApplication sharedApplication] applicationState];
            if (state == UIApplicationStateBackground || state == UIApplicationStateInactive) {
                // background
                
                if ([CHECK_NULL_STRING(model.type) isEqualToString: @"0"]) {
                    
                    if ([[Utility getCurrectViewController] isKindOfClass: [ExibitorVideoCallVC class]]) {
                        ExibitorVideoCallVC *vc = (ExibitorVideoCallVC *)[Utility getCurrectViewController];
                        vc.isPIPBtnCallEndClicked = YES;
                        [vc leaveChannel];
                        [vc.navigationController popToRootViewControllerAnimated: NO];
                    }else if ([[Utility getCurrectViewController] isKindOfClass: [ExhibitorCallingVC class]]) {
                        ExhibitorCallingVC *vc = (ExhibitorCallingVC *)[Utility getCurrectViewController];
                        [vc.navigationController popToRootViewControllerAnimated: NO];
                    }

                }
                else if ([CHECK_NULL_STRING(model.type) isEqualToString: @"1"]) {
                    if ([[Utility getCurrectViewController] isKindOfClass: [NotificationMessageVC class]]) {
                        ExibitorVideoCallVC *vc = (ExibitorVideoCallVC *)[Utility getCurrectViewController];
                        [vc.callingView setHidden: YES];
                    }
                }
            }
            
        }
        else if([model.strMessageType isEqualToString: kNotificationExhiVideoCall]) {
            
            UIApplicationState state = [[UIApplication sharedApplication] applicationState];
            if (state == UIApplicationStateBackground || state == UIApplicationStateInactive) {
                // background
                
                ExhibitorCallingVC *vc      = [[ExhibitorCallingVC alloc] init];
                UIViewController *currentVC = [Utility getCurrectViewController];
                
                vc.pushNotificationModel = model;
                
                pushFromViewCtrlToViewCtrlWithAnimation(currentVC, vc, NO);
            }
        }
       /* else if([model.strMessageType isEqualToString: kNotificationModeratorBroadcasting]) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                if ([[Utility getCurrectViewController] isKindOfClass: [AgendaSessionVideoStreamingVC class]]) {
                                    AgendaSessionVideoStreamingVC *vc = (AgendaSessionVideoStreamingVC *)[Utility getCurrectViewController];
                                    
                                    if ([CHECK_NULL_STRING(model.is_live) isEqualToString: @"1"]) {
                                                         
                                        vc.isAudience = false;
                                        [vc loadAgendaLiveStreamVC];
                                        
                //                        [vc.playerView stopVideo];
                //                        [vc.playerView setHidden:YES];
                //                        [vc.webView setHidden:YES];
                //                        vc.playerView = nil;
                //                        [vc.webView loadHTMLString:@"" baseURL:nil];
                //                        [vc.viewForWebView setHidden:NO];
                //                        [vc.contentView setHidden:NO];
                //
                //                        vc.agendaLiveStreamingVC.isFromBroadcasting = YES;
                //                        vc.agendaLiveStreamingVC.isAudience = NO;
                //
                //                        [vc loadAgendaLiveStreamVC];
                //                        [vc.agendaLiveStreamingVC loadAgoraKit];
                                    }
                                    else if ([CHECK_NULL_STRING(model.is_preview) isEqualToString: @"1"]) {

                //                        [vc.contentView setHidden:YES];
                //                        [vc loadVideoFromURL];
                //
                //                        vc.isAgendaStreamStarted = YES;
                //                        [vc startBroadcastTimer];
                //
                //                        vc.agendaLiveStreamingVC.isFromBroadcasting = YES;
                //                        vc.agendaLiveStreamingVC.isAudience = YES;
                //
                ////                        [vc loadAgendaLiveStreamVC];
                //                        [vc.agendaLiveStreamingVC leaveChannel];
                //                        [vc.agendaLiveStreamingVC loadAgoraKit];
                  
                                        vc.isAudience = true;
                                        [vc loadAgendaLiveStreamVC];
                                    }
                                    else if (![CHECK_NULL_STRING(model.is_video_link) isEqualToString: @""]) {
                                        [vc.agendaLiveStreamingVC leaveChannel];
                                        [vc loadVideoFromURL];
                                    }
                                }
            });
        }*/
        else  {
            if ([model.strMessageType isEqualToString:kNotificationGroup]){
                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]) {
                        AudioServicesPlaySystemSound(1007);
                    }
                }else{
                    AudioServicesPlaySystemSound(1007);
                }
            }else if ([model.strMessageType isEqualToString: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]) {
                        AudioServicesPlaySystemSound(1007);
                    }
                }else{
                    AudioServicesPlaySystemSound(1007);
                }
            }
            else if ([model.strMessageType isEqualToString: kNotificationAvailabelUser]) {
            }
            else {
                AudioServicesPlaySystemSound(1007);
            }
        }
        


        if(GetBoolForKey(IS_LOGIN))
        {
            [self performSelectorInBackground:@selector(managePushNotificationForgroundWithPushNotificationModel:) withObject:model];
        }
    }
    else
    {
        if(GetBoolForKey(IS_LOGIN))
        {
            if ([model.strMessageType isEqualToString:kNotificationUpdateGCMId]) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    [Utility logOutFromAppWithLogoutMessage:NO andLogoutStatus:@"0" andisUserLogsCall:NO];
                });
            }else {
                [self performSelectorInBackground:@selector(managePushNotificationBackgroundWithPushNotificationModel:) withObject:model];
            }
        }
    }
}
Editor is loading...
Leave a Comment