nomad-cli / houston

Apple Push Notifications; No Dirigible Required
http://nomad-cli.com
MIT License
2.93k stars 229 forks source link

Remote notification doesn't arrive on production server, but does on sandbox. #92

Closed ecnepsnai closed 9 years ago

ecnepsnai commented 9 years ago

Problem Description

I'm ready for my code to switch from the Sandbox APN server to the production server. I generated a production certificate and can successfully connect to the APN server with it. However when I try to manually send a notification it never arrives on the device, even though Houston is telling me that it was pushed.

I open my app in the release scheme and grab the APN token given to me by apple. I convert it into a NSString. Then, using the certificate I generated and tested, I run this command:

apn push "<apnstoken>" -c ck.pem -m "THIS BETTER WORK" -p

I type in my password and I see: 1 push notification sent successfully but I never actually see any notification on my device. This happens both with the CLI, and in code using the ruby gem:

apn = Houston::Client.production
apn.certificate = File.read("<pathtocert>")
apn.passphrase = '<password>'

# Create a notification that alerts a message to the user, plays a sound, and sets the badge on the app
notification = Houston::Notification.new(device: apntoken)
notification.alert = body
notification.custom_data = options

# Notifications can also change the badge count, have a custom sound, have a category identifier, indicate available Newsstand content, or pass along arbitrary data.
notification.content_available = true

# And... sent! That's all it takes.
apn.push(notification)

I'm used the same process for creating the cert as I did with the sandbox -- except I chose Production cert and not development. cert

And the code I'm using is the same with the updated password and change to Client.production.

Expected output

The notification arrive on my device

Actual output

A successful response, but no notification

Environmental information

kaneda commented 9 years ago

This sounds like an issue with APN. If you look at the APN specs they make a best effort to deliver with 24 hours.

ecnepsnai commented 9 years ago

I first noticed this issue a few days ago, so it's been well over 48 hours with no notifications on Production. But I still (just tried) get notifications on sandbox.

kaneda commented 9 years ago

Have you checked that your certs haven't expired?

ecnepsnai commented 9 years ago

As shown in the screenshot, they expire on March 28th, 2016. I can successfully connect to the APN production server using OpenSSL.

ecnepsnai commented 9 years ago

I checked my provisioning profile and app-id to make sure it allows for distribution remote notifications, and made the release scheme use the distribution profile. I get a different APN token, but it still doesn't work. qoncv

ecnepsnai commented 9 years ago

Don't know why it worked, but I recreated my production cert again. As well, I forgot to specify the environment in the APN command as the default is sandbox.

jaswinder-proptiger commented 6 years ago

Hi All, I am facing same issue. when using Houston::Client.development it is working but using Houston::Client.production is not.

if anyone found any solution for this please help ??.

damian-rzeszot commented 6 years ago

@jaswinder-proptiger: I assume you're using app built in xcode. That means it use sandbox server.There is two options to fix that: