Cloned from https://bitbucket.org/sardarnl/apns-client