ostinelli / apnotic

A Ruby APNs HTTP/2 gem able to provide instant feedback.
MIT License
480 stars 96 forks source link

ios13 voip push results in InvalidPushType error #87

Closed kelleyduran closed 3 years ago

kelleyduran commented 5 years ago

reproducible by using the following conditions

below is sample output of the error with token and apns-id scrubbed out

#<Apnotic::Notification:0x000000026efe40 @token="xxxxx", @apns_id="some-apns-id", @alert="Incoming call from 0000 test-push\n", @sound="ringtone.caf", @expiration=0, @custom_payload={"alert"=>"Incoming call from 0000"}>
push...
request headers: {"apns-id"=>"some-apns-id", "apns-expiration"=>0, "apns-push-type"=>"alert"}
response from push: #<Apnotic::Response:0x000000026dce58>
400
{":status"=>"400", "apns-id"=>"some-apns-id"}
{"reason"=>"InvalidPushType"}

Here is some sample code we used to test

require 'apnotic'

APNOTIC_POOL = Apnotic::ConnectionPool.new({
  cert_path: "certificate.pem",
  url:Apnotic::APPLE_DEVELOPMENT_SERVER_URL
}, size: 5) do |connection|
  connection.on(:error) { |exception| puts "Exception has been raised: #{exception}" }
end

# dev token
token = "xxxxx"
notif = Apnotic::Notification.new(token)
notif.alert = "Incoming call from 0000 test-push\n"
notif.sound = "ringtone.caf"
notif.expiration = 0

notif.custom_payload =  {
  "alert" => "Incoming call from 00000",
}
puts notif.inspect
APNOTIC_POOL.with do |apnotic|
  res = apnotic.push(notif, timeout:1)
  puts "response from push: #{res}"
  puts res.status
  puts res.headers
  puts res.body
end

what is interesting if we change the url to use the APPLE_PRODUCTION_SERVER, the push goes out fine.

When researching I found this thread: https://forums.developer.apple.com/thread/122904 where one post details that adding voip type resolves the issue.

aleksey-alt commented 5 years ago

We have this issue with 1.6.0 too.

@ostinelli Apple already published possible values for apns-push-type header: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns Are you going to fix the issue?

kelleyduran commented 5 years ago

There are new push types listed in the apple documentation and currently, 1.6.0 has 2 push types: alert and background

The new added ones are voip mdm fileprovider complication

benubois commented 3 years ago

Closing in favor of #88.