Why do I get a type mismatch when using “this” on fragment Kotlin

I can scan a barcode successfully but I somehow cannot get the result. I found out that since I am calling the barcode scanner in a fragment, I need change my code to use this:

class AddIerFragment : Fragment() { ....

   val intentIntegrator = IntentIntegrator.forFragment(this)
   ....
}

The problem is, the “this” keyword is not allowed because it gives me an error of

Type mismatch
Requred: Fragment
Found AddIerFragment

See image below.

enter image description here

I have this code in the fragment

companion object {
        @JvmStatic
        fun newInstance(param1: String, param2: String) =
            AddIerFragment().apply {
                arguments = Bundle().apply {
                }
            }
        private const val CAMERA = 1
        private const val GALLERY = 2
        private const val SCAN = 3
    }

R.id.button_atgScan -> {
                Dexter.withContext(context!!).withPermissions(
                    Manifest.permission.READ_EXTERNAL_STORAGE,
                    Manifest.permission.CAMERA
                )
                    .withListener(object: MultiplePermissionsListener {
                        override fun onPermissionsChecked(report: MultiplePermissionsReport?) {
                            report?.let{
                                if(report!!.areAllPermissionsGranted()) {
                                    
                       
                       
    intentIntegrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES)
                                    intentIntegrator.setPrompt("Scan a barcode")
                                    intentIntegrator.setCameraId(0)
                                    intentIntegrator.setBeepEnabled(false)
                                    intentIntegrator.setBarcodeImageEnabled(true)
                                    intentIntegrator.setOrientationLocked(false)
                                    intentIntegrator.initiateScan()

                                }
                            }

                        }

                        override fun onPermissionRationaleShouldBeShown(
                            p0: MutableList<PermissionRequest>?,
                            p1: PermissionToken?
                        ) {
                            showRationalDialogForPermission()
                        }

                    }).onSameThread().check()
            }

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == GALLERY) {
            data?.let {
                val selectedPhotoUri = data.data
                file = File(getPath(selectedPhotoUri))
                gView!!.iv_ier_image.setImageURI(selectedPhotoUri)
            }
        } else if (requestCode == CAMERA) {
            data?.extras?.let {
                val thumbnail: Bitmap =
                    data.extras!!.get("data") as Bitmap
                file = savebitmap(thumbnail)!!
                gView!!.iv_ier_image.setImageBitmap(thumbnail)
            }
        }

        val result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data)
        if (result != null) {
            if (result.contents == null) {
                Log.i("TAG", "NOTHING")
            } else {
                Log.i("TAG", result.contents)
            }
        } else {
            super.onActivityResult(requestCode, resultCode, data)
        }
    }

Answer

For support or androidx fragments you should use IntentIntegrator.forSupportFragment(this)