There is another type of magnet that you don’t have to sew on. You just have to mark where you want to put the magnet. These magnets have little sharp points for you to stick into the fabric and close the points for it to stay.
I usually put an extra piece of small fabric around the magnet if the fabric is light weight, to give it more strength, so the magnet wouldn’t come apart. If the fabric is thick, you don’t need the extra fabric.