(Abridged) We present a method that tracks the growth of supermassive black holes (BHs) and the feedback from AGN in cosmological simulations. Our model is a substantially modified version of the one by Springel et al. (2005). Because cosmological simulations lack both the resolution and the physics to model the multiphase interstellar medium, they tend to strongly underestimate the Bondi-Hoyle accretion rate. To allow low-mass BHs to grow, it is therefore necessary to increase the predicted Bondi-Hoyle rates in dense gas by large, ad-hoc factors. We explore the physical regimes where the use of such factors is reasonable, and through this introduce a new prescription for gas accretion. Feedback from AGN is modeled by coupling a fraction of the rest-mass energy of the accreted gas thermally into the surrounding medium. We describe the implementation as well as the limitations of the model and motivate all the changes relative to previous work. We investigate the robustness of the predictions for the cosmic star formation history, the redshift zero cosmic BH density, BH scaling relations, and galaxy specific star formation rates. We find that the freedom introduced by the need to increase the predicted accretion rates, the standard procedure in the literature, is the most significant source of uncertainty. Our simulations demonstrate that supermassive BHs are able to regulate their growth by releasing a fixed amount of energy for a given halo mass, independent of the assumed efficiency of AGN feedback, which sets the normalization of the BH scaling relations. Regardless of whether BH seeds are initially placed above or below the BH scaling relations they grow onto the same relations. AGN feedback efficiently suppresses star formation in high-mass galaxies.