Write optimistically and check for errors only on write failures

As per recommendations in Apple Technical Note 2265
Merge branch 'master' of github.com:FootballAddicts/apn_client
Merge branch 'master' of github.com:FootballAddicts/apn_client