Fixed an APNS sandbox issue

- Replaced an old constant that used to switch between sandbox mode and
production mode -- pull it from value in datastore instead.

- also added some todo comments, and some other minor formatting