Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
jirapong-apn_on_rails
Advanced tools
=APN on Rails (Apple Push Notifications on Rails)
APN on Rails is a Ruby on Rails gem that allows you to easily add Apple Push Notification (iPhone) support to your Rails application.
It supports:
== Feature Descriptions
Multiple iPhone Apps: In previous versions of this gem a single Rails application was set up to manage push notifications for a single iPhone app. In many cases it is useful to have a single Rails app manage push notifications for multiple iPhone apps. With the addition of an APN::App model, this is now possible. The certificates are now stored on instances of APN::App and devices are intended to be associated with a particular app. For compatibility with existing implementations it is still possible to create devices that are not associated with an APN::App and to send individual notifications to them using the certs stored in the config directory.
Individual and Group Notifications: Previous versions of this gem treated each notification individually and did not provide a built-in way to send a broadcast notification to a group of devices. Group notifications are now built into the gem. A group notification is associated with a group of devices and shares its contents across the entire group of devices. (Group notifications are only available for groups of devices associated with an APN::App)
Notification Content Areas: Notifications may contain alerts, badges, sounds, and custom properties.
Pull Notifications: This version of the gem supports an alternative notification method that relies on pulls from client devices and does not interact with the Apple Push Notification servers. This feature may be used entirely independently of the push notification features. Pull notifications may be created for an app. A client app can query for the most recent pull notification available since a given date to retrieve any notifications waiting for it.
==Version 0.4.1 Notes
==Acknowledgements:
From Mark Bates:
This gem is a re-write of a plugin that was written by Fabien Penso and Sam Soffes. Their plugin was a great start, but it just didn't quite reach the level I hoped it would. I've re-written, as a gem, added a ton of tests, and I would like to think that I made it a little nicer and easier to use.
From Rebecca Nesson (PRX.org):
This gem extends the original version that Mark Bates adapted. His gem did the hard work of setting up and handling all communication with the Apple push notification servers.
==Converting Your Certificate:
Once you have the certificate from Apple for your application, export your key and the apple certificate as p12 files. Here is a quick walkthrough on how to do this:
Export 2 items...
.cert.p12
.Now covert the p12 file to a pem file:
$ openssl pkcs12 -in cert.p12 -out apple_push_notification_production.pem -nodes -clcerts
If you are using a development certificate, then change the name to apple_push_notification_development.pem instead.
Store the contents of the certificate files on the app model for the app you want to send notifications to.
==Installing:
===Stable (RubyForge):
$ sudo gem install apn_on_rails
===Edge (GitHub):
$ sudo gem install PRX-apn_on_rails.git --source=http://gems.github.com
===Rails Gem Management:
If you like to use the built in Rails gem management:
config.gem 'apn_on_rails'
Or, if you like to live on the edge:
config.gem 'PRX-apn_on_rails', :lib => 'apn_on_rails', :source => 'http://gems.github.com'
==Setup and Configuration:
Once you have the gem installed via your favorite gem installation, you need to require it so you can start to use it:
Add the following require, wherever it makes sense to you:
require 'apn_on_rails'
You also need to add the following to your Rakefile so you can use the Rake tasks that ship with APN on Rails:
begin require 'apn_on_rails_tasks' rescue MissingSourceFile => e puts e.message end
Now, to create the tables you need for APN on Rails, run the following task:
$ ruby script/generate apn_migrations
APN on Rails uses the Configatron gem, http://github.com/markbates/configatron/tree/master, to configure itself. (With the change to multi-app support, the certifications are stored in the database rather than in the config directory, however, it is still possible to use the default "app" and the certificates stored in the config directory. For this setup, the following configurations apply.) APN on Rails has the following default configurations that you change as you see fit:
configatron.apn.passphrase # => '' configatron.apn.port # => 2195 configatron.apn.host # => 'gateway.sandbox.push.apple.com' configatron.apn.cert #=> File.join(RAILS_ROOT, 'config', 'apple_push_notification_development.pem')
configatron.apn.host # => 'gateway.push.apple.com' configatron.apn.cert #=> File.join(RAILS_ROOT, 'config', 'apple_push_notification_production.pem')
configatron.apn.feedback.passphrase # => '' configatron.apn.feedback.port # => 2196 configatron.apn.feedback.host # => 'feedback.sandbox.push.apple.com' configatron.apn.feedback.cert #=> File.join(RAILS_ROOT, 'config', 'apple_push_notification_development.pem')
configatron.apn.feedback.host # => 'feedback.push.apple.com' configatron.apn.feedback.cert #=> File.join(RAILS_ROOT, 'config', 'apple_push_notification_production.pem')
That's it, now you're ready to start creating notifications.
===Upgrade Notes:
If you are upgrading to a new version of APN on Rails you should always run:
$ ruby script/generate apn_migrations
That way you ensure you have the latest version of the database tables needed.
==Example (assuming you have created an app and stored your keys on it):
$ ./script/console
app = APN::App.create(:name => "My App", :apn_dev_cert => "PASTE YOUR DEV CERT HERE", :apn_prod_cert => "PASTE YOUR PROD CERT HERE") device = APN::Device.create(:token => "XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX",:app_id => app.id) notification = APN::Notification.new notification.device = device notification.badge = 5 notification.sound = true notification.alert = "foobar" notification.custom_properties = {:link => "http://www.prx.org"} notification.save
You can use the following Rake task to deliver your individual notifications:
$ rake apn:notifications:deliver
And the following task to deliver your group notifications:
$ rake apn:group_notifications:deliver
The Rake task will find any unsent notifications in the database. If there aren't any notifications it will simply do nothing. If there are notifications waiting to be delivered it will open a single connection to Apple and push all the notifications through that one connection. Apple does not like people opening/closing connections constantly, so it's pretty important that you are careful about batching up your notifications so Apple doesn't shut you down.
Released under the MIT license.
FAQs
Unknown package
We found that jirapong-apn_on_rails demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.