Show the first Chern class of a $U(1)$ bundle is integral. I am working from John Baez's book: "Gauge Fields, Knots and Gravity". So I will stick to the notation used in that book.
I am stuck at exercise 122 of part II (page 283), it reads:

Show that if $E$ is a $U(1)$-bundle over $M$ with standard fiber given by the fundamental representation $U(1)$, the first Chern class of $E$ is integral.

So I need to show that $i/(2\pi) \int_{M} \text{tr}F$, where $F$ is the ($\text{End}(E)$-valued) curvature two-form, is an integer.
Now just before the exercise he says that one can turn the argument for charge quantization in Chapter 6 of part I (at the very end) into a proof of the integrality of the first Chern class for a $U(1)$-connection.
This is the argument (paraphrased):
The space we consider is $\mathbb{R}^{3}\setminus \{0 \}$.
If we drag a particle with electric charge $q$ around a loop $\gamma$ that bounds a $2$-disk $D$ embedded in space, its wavefunction is multiplied by a phase
\begin{equation}
e^{-iq/\hbar\int_{D} B},
\end{equation}
where $B$ is the magnetic field two-form, given by
\begin{equation}
B = (m/4\pi) \sin \phi \text{d}\theta \wedge \text{d}\phi.
\end{equation}
Suppose that the loop $\gamma$ is the equator of a sphere centered on the origin. Let $D_{1}$ be the northern half of this sphere and $D_{2}$ the southern half. We compute
\begin{equation}
\int_{D_{1}} B = \frac{m}{4\pi} \int_{0}^{\pi/2} \int_{0}^{2\pi} \sin \phi \text{d}\theta \wedge \text{d}\phi = \frac{m}{2},
\end{equation}
and
\begin{equation}
\int_{D_{2}} B = -\frac{m}{4\pi} \int_{\pi/2}^{\pi} \int_{0}^{2\pi} \sin \phi \text{d}\theta \wedge \text{d}\phi = -\frac{m}{2}.
\end{equation}
We should be able to compute the phase using either of these results, thus we are led to conclude
\begin{equation}
e^{-\frac{iqm}{2\hbar}} = e^{\frac{iqm}{2\hbar}},
\end{equation}
or
\begin{equation}
e^{\frac{iqm}{\pi}} = 1,
\end{equation}
thus $q$ must be an integer multiple of $2\pi \hbar/m$, that is, charge is quantized.
Furthermore, right before the exercise, there is an argument that shows that the fact that the first Chern class is integral implies that the magnetic charge is quantized. It goes as follows (also paraphrased):
Let $E$ be a (the?) $U(1)$-bundle over $\mathbb{R}^{3} \setminus \{0 \}$. Let $D$ be a $U(1)$-connection on $E$ and let $A$ be the corresponding vector potential, (that is, $D = D^{0} + A$, where $D^{0}$ is a flat connection). Let $F$ be the curvature of $D$ (equivalently of $A$). Define $\text{tr}(F)=:i B$, such that $B$ is a real-valued $2$-form on $\mathbb{R}^{3} \setminus \{0 \}$. By the integrality of the first Chern class we have
\begin{equation}
\int_{S^{2}} B = 2 \pi N,
\end{equation}
thus the magnetic charge is quantized.
So here is my attempt at a solution to the problem.
Let $E$ be a $U(1)$-bundle over $M$ as in the problem. Let $D$ be a connection on $E$ with corresponding vector potential $A$ and let $F$ be the curvature of $D$. We define the real valued two-form $B$ by $B:= -i \text{tr}(F)$. Now I suppose one would like to mimic the earlier proof and say that if one carries a particle with charge $q$ around a loop $\gamma$ in $M$ its wave function would be multiplied by a factor
\begin{equation}
e^{-\frac{i}{\hbar}\int_{D} B},
\end{equation}
where $D$ is a disk enclosed by the loop $\gamma$, but here I have some doubts, since it might not be possible to make such a disk if $M$ is not simply connected, and even worse I am not sure this needs to be true. And even if there is a way around these objections, I would not know how to continue since in the argument I am trying to mimic one explicitly computes $\int_{D} B$, but I am not sure how to do this without explicit knowledge of the manifold $M$.
Any help would be greatly appreciated!
 A: A postdoc at my university gave me the answer, which I then typed up. I am not 100% sure about the details, but this should more or less do it.
Claim: The first Chern class
\begin{equation*}
 \frac{i}{2\pi} F,
\end{equation*}
is integral.
The claim says that for any (compact?) two-dimensional oriented submanifold without boundary $\Sigma \subseteq M$ we have that
\begin{equation*}
 \frac{i}{2\pi} \int_{\Sigma} F
\end{equation*}
is an integer. So let $\Sigma \subseteq M$ be an arbitrary submanifold without boundary. Choose an arbitrary point $\xi \in \Sigma$ and let $U \subseteq \Sigma$ be a coordinate patch around $\xi$. Let $\gamma: S^{1} \rightarrow U$ be a loop around $\xi$. The loop $\gamma$ cuts the surface $\Sigma$ into two pieces $\Sigma^{+}$ and $\Sigma^{-}$ such that $\Sigma^{+} \cap \Sigma^{-} = \gamma$ (we use $\gamma$ interchangably for both the map $\gamma: S^{1} \rightarrow \Sigma$ and for the submanifold defined by the map), and such that the boundary of $\Sigma^{+}$ is $\partial \Sigma^{+} = \gamma$ and the boundary of $\Sigma^{-}$ is $\partial \Sigma^{-} = \gamma^{-1}$, where $\gamma^{-1}$ denotes the loop $\gamma$, but with opposite orientation.
Now, let $D$ be a (the?) connection with curvature $F$. Let $(U_{i})_{i \in I}$ be a finite collection of coordinate charts covering $\Sigma^{+}$ and trivializing $E$ over $\Sigma$. Let $(\gamma_{i})_{i \in I}$ be a collection of loops such that
\begin{equation*}
 \prod_{i \in I} \gamma_{i} = \gamma,
\end{equation*}
and such that for each $i \in I$ the loop $\gamma_{i}$ lands in $U_{i}$. It follows that
\begin{equation*}
 \prod_{i \in I} H(\gamma_{i}, D) = H(\gamma, D).
\end{equation*}
Then, locally, that is for each $U_i$, we can write $D = D^0 + A$, where $D^0$ is the standard flat connection on $U_i$ and $A$ is an $\text{End}(E)$-valued $1$-form, with $F = d A$. We may now compute the holonomy of the connection $D$ around the loop $\gamma_i$ as follows
\begin{equation*}
 H(\gamma_i, D) =  e^{-\int_{\gamma_i}A}.
\end{equation*}
Now let $\Sigma_i \subseteq{\Sigma}$ be the area enclosed by the loop $\gamma_{i}$, i.e. such that $\partial \Sigma_i = \gamma_i$. By Stokes' theorem it follows that
\begin{equation*}
 H(\gamma_i, D) = e^{-\int_{\Sigma_i} \text{d} A} = e^{ -\int_{\Sigma_i} F}.
\end{equation*}
Thus we see that
\begin{equation*}
 H(\gamma, D) = \prod_{i \in I} H(\gamma_i, D) = e^{-\sum_{i \in I} \int_{\Sigma_i} F } = e^{-\int_{\Sigma^{+}} F}.
\end{equation*}
The same procedure shows that
\begin{equation*}
 H(\gamma^{-1},D) = e^{- \int_{\Sigma^{-}} F}.
\end{equation*}
So we conclude that
\begin{equation*}
 1 = H(\gamma, D) H(\gamma^{-1}, D) = e^{- \int_{\Sigma^{+}} F - \int_{\Sigma^{-}} F} = e^{- \int_{\Sigma} F},
\end{equation*}
thus $- \int_{\Sigma} F = 2 \pi i k$, with $k \in \mathbb{Z}$, as required.
