jpoz / apns Goto Github PK
View Code? Open in Web Editor NEWAn Apple Push Notification Service gem
License: MIT License
An Apple Push Notification Service gem
License: MIT License
I have a view, which should send push messages. As soon as I enter umlauts in my text, it is not submitted. This can be reproduced like this:
device_token = '123abc456def'
APNS.send_notification(device_token, :alert => 'Hellö iPhöné', :badge => 1, :sound => 'default')
I am using ruby 1.9 and Rails 3.0.x. Thanks for your help. For plain ASCII messages though your gem rocks!
I'm using this gem to send iOS notifications it's working in development but not in production and there is no error.
Generated .pem with private key without password.
I'm observing an issue with the batch notifications method send_notifications
If one of the device token in the request is incorrect due to any reason, the batch notification would stop at the bad token without any error response. An example as the following:
Is it possible to fix this issue?
Hi,
I have a fairly large iOS user base, feedback service returns plenty of stuff all the time.
This script, though:
#!/usr/bin/env ruby
require 'rubygems'
require 'apns'
require 'socket'
require 'openssl'
require 'base64'
APNS.pem = 'production.pem'
APNS.host = 'gateway.push.apple.com'
APNS.feedback.each {|e| puts e}
Returns results like this:
feedback.push.apple.com
1982-03-27 11:27:14 +0100
9f389bede247500458c16d80de8af8ef8d05af28c313889b13eaecd77305fc8ad8d76c672df29a6a1ed0be63a89947895c6bce462d803999214e8739c31537e5cf322586136b
I've got all sort of crazy dates, including:
1982-03-27 11:27:13 +0100
2049-10-21 12:29:29 +0200
2009-04-13 11:04:07 +0200
2037-07-24 23:24:17 +0200
And the token never matches any of the tokens I have in my database. Notice that I can use the configuration above to send push notifications via APNS without any problem.
Am I doing something wrong here or there is a problem?
https://github.com/jpoz/APNS/blob/master/apns.gemspec#L5 says 1.0.0
but then, https://github.com/jpoz/APNS/blob/master/Gemfile.lock#L4 says 0.0.9
,
so the gem i get with gem 'apns'
is apns (0.9.0)
.
Could you bump it to 1.0.0, please?
Hello,
I've it all installed but I haven't seem any APNS class file to setup host, pem and port. No configurations file at all were created when I installed the gem.
What am I missing?
Thanks!
Does anybody know how to do this? I've seen applications like Mailboxapp update the counter quietly without posting a message for the app, but I haven't been able to do it.
If it's possible, it'd be great to document how to do it in the readme.
Hi jpoz,
I'm trying to use silent push notification, and it seen need to provide the key "content-available" with a value of 1, so that I can use it. But, when I write:
APNS.send_notification(device_token, :content-available => 1}
It'll send a syntax error message. How can I solve it?
Hello, I'm using your gem for one of my project.
The project allows the user to send a push notification of an event, a user can have multiple events.
When I use this code to send the push:
push_notification.devices.each do |d|
APNS.send_notification(d.token, :alert => push_notification.event.title, :badge => 0, :sound => 'default', :other => {:event_id => push_notification.event.id})
end
everything works fine.
if insteas I use this code
pushes = []
push_notification.devices.each do |d|
pushes << APNS::Notification.new(d.token, :alert => push_notification.event.title, :badge => 0, :sound => 'default', :other => {:event_id => push_notification.event.id})
end
APNS.send_notifications(pushes)
I receive, on the phone side, pushes for events I pushed even yesterday (actually for all the events that have been pushed).
I'm not saying this is a bug of your gem, maybe it's about the way the apple manages the push requests, just to let you know.
Any idea when you'll push 1.1.0 to rubygems.org? From what I can tell 1.0.0 is the most recent version?
Thanks!
Susheel
$ cat Gemfile source :rubygems gem 'apns' irb(main):002:0> require 'bundler/setup' => true irb(main):004:0> require 'apns' LoadError: no such file to load -- json from /usr/local/lib/ruby/gems/1.8/gems/apns-0.9.0/lib/apns/core.rb:4:in `require' from /usr/local/lib/ruby/gems/1.8/gems/apns-0.9.0/lib/apns/core.rb:4 from /usr/local/lib/ruby/gems/1.8/gems/apns-0.9.0/lib/apns.rb:1:in `require' from /usr/local/lib/ruby/gems/1.8/gems/apns-0.9.0/lib/apns.rb:1 from (irb):4:in `require' from (irb):4
As json is used the gemspec should declare a dependency on it.
APNS appears to close the connection after each message (or group of messages). From the APNS documentation:
Keep your connections with APNs open across multiple notifications; don’t repeatedly open and close connections. APNs treats rapid connection and disconnection as a denial-of-service attack. You should leave a connection open unless you know it will be idle for an extended period of time—for example, if you only send notifications to your users once a day it is ok to use a new connection each day.
In the worst case scenario, I could see Apple revoking your push certificate should your volume increase to the point they consider it a DDOS attack.
Hi all,
I spent hours of debugging to find out that the notification didn't work because of the 256 bytes limitation.
It would be nice to raise an error when the payload exceeds 256 bytes.
Would a raise "Error" if message.to_json.size > 256
work in Notification.initialize(device_token, message) ?
Hello!
I wanted to ask if the feedback method works. If it does could this be released as a gem?
Thanks :)
I'm using following for sending the notification.
APNS.host = 'gateway.push.apple.com'
APNS.pem = "#{Rails.root}/doc/pushcert.pem"
APNS.port = 2195
APNS.send_notification(token, message)
but all it is returning is nil
and notifications are not being sent and all the associated article call APNs a black box with not round about for this.
Is there any way to figure out the errors and reasons for notifications not being delivered ?
?
Is there a way to get this gem to work behind a proxy?
RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can image, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.
There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.
I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!
Appendix:
If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies
p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.
I am getting below error when try to send the push notifications, its working fine couple of times but when I tried after some time its not working:
Please suggest how can I fixed that issue. My app is hosted on heroku.
Thanks
How should I enter passphrase when sending notification?
I am using apns on a legacy app with following specs. We can't upgrade it rails latest version, so we are looking for solution like upgrading apns only or some monkey patch if possible.
Rails 3.2
Ruby 1.9.3
APNS 1.0.0
mysql 0.3.18
I am not able to send emoji to iOS application in alert dictionary. Emojis are saved in a field along text data in table.
APNS.send_notification(device_token, alert: { title: "New Room!", body: "We can talk about anything here \\ud83c\\udfc0\\ud83c\\udfe0\\ud83d\\udcb4" }, badge: 0, sound: "default", other:
{ info: { type: 'new_room', bug_id: 1, bug_name: "We can talk about anything here \\ud83c\\udfc0\\ud83c\\udfe0\\ud83d\\udcb4", :bug_creator_id => 5, bug_creator_name: 'Zeeshan'}} )
```
I want to push messages to many of my apps, and it needs to config more than one pem file, is it possible ?
I am getting this issue many times, is it bug with this gem
I'm having trouble with explicitly tell APNs to send out notifications of https. Is there a way to accomplish this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.