application/modules/api_v1/controllers/User.php
//When buyer give review to seller
When buyer give review to seller
When buyer give review to seller
function reviewNotification($userDeviceTokens,$user_id,$full_name,$insertReview,$ratingInfo,$orderID){
        if(!empty($userDeviceTokens)){
            $badgeNotify = 0;
            $val = $this->database->getReference($this->dbname)->getChild($ratingInfo->rating_for)->getSnapshot();
            if($val->exists() == TRUE){
                $badgeCount = intval($val->getValue()['count']);
                $badgeCountValue = $badgeCount ? $badgeCount : 0;
                $badgeNotify = $badgeCountValue+1;
                $updateVal = $this->database->getReference($this->dbname)->getChild($ratingInfo->rating_for)->update(['count' => $badgeCountValue+1]); 
            }else{
                $updateVal = $this->database->getReference($this->dbname)->getChild($ratingInfo->rating_for)->update(['count' => 1]); 
                $badgeNotify = 1;
            }
            $tokenArr = array();
            foreach ($userDeviceTokens as $value) {
                $tokenArr[] = $value->device_token; 
                $notif_msg['type']          = 'Seller Review';
                $notif_msg['body']          = 'You have new review by '.$full_name;
                $notif_msg['title']         = 'Got New Review';
                $notif_msg['sound']         = 'default';
                $notif_msg['order_id']      = $orderID;  
                $notif_msg['badge']      = $badgeNotify;
                $dataNotifiy['notification_title']      = 'Got New Review';
                $dataNotifiy['notification_by']         = $user_id;
                $dataNotifiy['notification_for']        = $value->user_id;
                $dataNotifiy['notification_type']       = 'Seller Review';
                $dataNotifiy['is_read']                 = '0';
                $dataNotifiy['web_push']                 = '0';
                $dataNotifiy['reference_id']            = $orderID;
                $dataNotifiy['updated_at']            = datetime();
                $dataNotifiy['created_at']            = datetime();
                $dataNotifiy['notification_payload']    = json_encode($notif_msg);
                $dataNotifiy['notification_message']    = 'You have new review by '.$full_name;
                $this->payment_model->notification($dataNotifiy,$tokenArr,$notif_msg);
                $tokenArr = array();
                $buyerID = $value->user_id;
            }
        }
        $notif_msg['type']          = 'Seller Review';
        $notif_msg['body']          = 'You have new review by '.$full_name;
        $notif_msg['title']         = 'Got New Review';
        $notif_msg['sound']         = 'default';
        $notif_msg['order_id']      = $orderID;
        $dataNotifiy['notification_title']      = 'Got New Review';
        $dataNotifiy['notification_by']         = $user_id;
        $dataNotifiy['notification_for']        = $ratingInfo->rating_for;
        $dataNotifiy['notification_type']       = 'Seller Review';
        $dataNotifiy['is_read']                 = '0';
        $dataNotifiy['web_push']                 = '0';
        $dataNotifiy['reference_id']            = $orderID;
        $dataNotifiy['updated_at']            = datetime();
        $dataNotifiy['created_at']            = datetime();
        $dataNotifiy['notification_payload']    = json_encode($notif_msg);
        $dataNotifiy['notification_message']    = 'You have new review by '.$full_name;
        $this->notification_model->save_notification($dataNotifiy);
    }
function reviewNotification ( $ userDeviceTokens , $ user_id , $ full_name , $ insertReview , $ ratingInfo , $ orderID ) { if ( ! empty ( $ userDeviceTokens ) ) { $ badgeNotify = 0 ; $ val = $ this -> database -> getReference ( $ this -> dbname ) -> getChild ( $ ratingInfo -> rating_for ) -> getSnapshot ( ) ; if ( $ val -> exists ( ) == TRUE ) { $ badgeCount = intval ( $ val -> getValue ( ) [ 'count' ] ) ; $ badgeCountValue = $ badgeCount ? $ badgeCount : 0 ; $ badgeNotify = $ badgeCountValue + 1 ; $ updateVal = $ this -> database -> getReference ( $ this -> dbname ) -> getChild ( $ ratingInfo -> rating_for ) -> update ( [ 'count' => $ badgeCountValue + 1 ] ) ; } else { $ updateVal = $ this -> database -> getReference ( $ this -> dbname ) -> getChild ( $ ratingInfo -> rating_for ) -> update ( [ 'count' => 1 ] ) ; $ badgeNotify = 1 ; } $ tokenArr = array ( ) ; foreach ( $ userDeviceTokens as $ value ) { $ tokenArr [ ] = $ value -> device_token ; $ notif_msg [ 'type' ] = 'Seller Review' ; $ notif_msg [ 'body' ] = 'You have new review by ' . $ full_name ; $ notif_msg [ 'title' ] = 'Got New Review' ; $ notif_msg [ 'sound' ] = 'default' ; $ notif_msg [ 'order_id' ] = $ orderID ; $ notif_msg [ 'badge' ] = $ badgeNotify ; $ dataNotifiy [ 'notification_title' ] = 'Got New Review' ; $ dataNotifiy [ 'notification_by' ] = $ user_id ; $ dataNotifiy [ 'notification_for' ] = $ value -> user_id ; $ dataNotifiy [ 'notification_type' ] = 'Seller Review' ; $ dataNotifiy [ 'is_read' ] = '0' ; $ dataNotifiy [ 'web_push' ] = '0' ; $ dataNotifiy [ 'reference_id' ] = $ orderID ; $ dataNotifiy [ 'updated_at' ] = datetime ( ) ; $ dataNotifiy [ 'created_at' ] = datetime ( ) ; $ dataNotifiy [ 'notification_payload' ] = json_encode ( $ notif_msg ) ; $ dataNotifiy [ 'notification_message' ] = 'You have new review by ' . $ full_name ; $ this -> payment_model -> notification ( $ dataNotifiy , $ tokenArr , $ notif_msg ) ; $ tokenArr = array ( ) ; $ buyerID = $ value -> user_id ; } } $ notif_msg [ 'type' ] = 'Seller Review' ; $ notif_msg [ 'body' ] = 'You have new review by ' . $ full_name ; $ notif_msg [ 'title' ] = 'Got New Review' ; $ notif_msg [ 'sound' ] = 'default' ; $ notif_msg [ 'order_id' ] = $ orderID ; $ dataNotifiy [ 'notification_title' ] = 'Got New Review' ; $ dataNotifiy [ 'notification_by' ] = $ user_id ; $ dataNotifiy [ 'notification_for' ] = $ ratingInfo -> rating_for ; $ dataNotifiy [ 'notification_type' ] = 'Seller Review' ; $ dataNotifiy [ 'is_read' ] = '0' ; $ dataNotifiy [ 'web_push' ] = '0' ; $ dataNotifiy [ 'reference_id' ] = $ orderID ; $ dataNotifiy [ 'updated_at' ] = datetime ( ) ; $ dataNotifiy [ 'created_at' ] = datetime ( ) ; $ dataNotifiy [ 'notification_payload' ] = json_encode ( $ notif_msg ) ; $ dataNotifiy [ 'notification_message' ] = 'You have new review by ' . $ full_name ; $ this -> notification_model -> save_notification ( $ dataNotifiy ) ; }
When buyer give review to seller
When buyer give review to seller
//Update badge count Code //update badge count //create new badge count //End Of Update badge count Code //$refrenID['token'] = $value->device_token; //device token for push notification //device token for push notification //Review ID // if($value->device_type < 1){ //     $dataNotifiy['web_push']                 = '1'; // } //when reference id is not empty then notification done //if(!empty($refrenID['token'])){ //}