Cosmology with gamma-rays detected by Fermi