ostinelli / apnotic

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

Notifications are not displayed on devices #84

Closed gordienko closed 3 years ago

gordienko commented 5 years ago

Notifications are not displayed on devices

To generate maps, I use a sinatra based solution, https://github.com/ShallyBanh/KdanFriender.

I modified the script to send a notification as follows:

require 'rubygems'
require 'sequel'
require 'apnotic'

# Setup data access 
DB = Sequel.sqlite("../data/pass_server.sqlite3")
@registrations = DB[:registrations]

connection = Apnotic::Connection.new(cert_path: "../data/Certificate/cert.p12", cert_pass: "", url: "https://api.push.apple.com:443")
puts "Opening connection to APNS."

# Get the list of registered devices and send a push notification
@push_tokens = @registrations.collect{|r| r[:push_token]}.uniq
@push_tokens.each do |push_token|
  puts "Sending a notification to #{push_token}"
  notification       = Apnotic::Notification.new(push_token)
  notification.alert = "Notification from Apnotic!"
  response = connection.push(notification)
  puts response.ok?
  puts response.status
  puts response.headers
  puts response.body
end

connection.close
puts "APNS connection closed."

When starting in the console, I get the following output:

Opening connection to APNS.
Sending a notification to aa8a5640f0fdd83d4b2f5c721b1ef517eaadf839b464795e598bbaefc7dc1d58
true
200
{":status"=>"200", "apns-id"=>"e238ddfa-76ba-4ef2-9e55-620594b89218"}

Sending a notification to 3857e85f75d48ad117dc9b9d69994cea3e0c26044bca88ae025d60c22d011bec
true
200
{":status"=>"200", "apns-id"=>"cf06db2f-29c4-452d-876c-7032e7192d0b"}

APNS connection closed.

But on the devices I do not see the notifications! I use a Certificate Type: Pass Type ID certificate.

What am I doing wrong? Where can I see the debug information on the notification?

ostinelli commented 5 years ago

If Apple returns a 200 code there’s nothing much more to that. My best bet would be a mismatch of production vs development servers.

niklat22 commented 4 years ago

Can i get click event for notification click?

Like notification action button or popup click.

benubois commented 3 years ago

This does not appear to be an apnotic issue if it's reporting a successful response.