I'm not a dev or anything but there are a couple of apps in the store same purpose (free to use) may be you can have a look at their code, no ?