yuki24 / pushing

Finally, push notification framework that does not hurt. currently supports Android (FCM) and iOS (APNs)
MIT License
46 stars 6 forks source link

Capture client error responses from APNs with rescue_with Fourseam::ApnDeliveryError #4

Closed yuki24 closed 7 years ago

yuki24 commented 7 years ago

APNs' device tokens could expire and user should be able to capture errors from APNs:

class ApplicationNotifier < Fourseam::Base
  rescue_from Fourseam::ApnDeliveryError do |error|
    response = error.response

    if response&.status == '410' || (response&.status == '400' && response&.body['reason'] == 'BadDeviceToken')
      # delete device token accordingly
    else
      raise # Make sure to raise any other types of error to re-enqueue the job
    end
  end
end