Skip to content

Files

Latest commit

 

History

History
54 lines (34 loc) · 1.84 KB

push-notifications.md

File metadata and controls

54 lines (34 loc) · 1.84 KB

push-notifications gem - iOS, Android and Windows Phone Push Notifications made easy

Do you have a mobile app? Do you push notifications to them? Do you want to keep it easy? Read on!

Push Notifications makes it easy to Push Notifications to you users' devices by providing a common interface, regardless of the device's manufacturer (currently iOS, Android and Windows Phone supported).

The general steps to push a notification are (Using iOS interface for this example):

  1. Create one (or more) notifications.
tokens = [
  'First token here',
  'Second token here'
]

notification = RubyPushNotifications::APNS::APNSNotification.new tokens, { aps: { alert: 'Hello APNS World!', sound: 'true', badge: 1 } }
  1. Create the corresponding pusher
pusher = RubyPushNotifications::APNS::APNSPusher.new(File.read('/path/to/your/apps/certificate.pem'), true)
  1. Push!
pusher.push [notification]
  1. Get Feedback
p 'Notification sending results:'
p "Success: #{notification.success}, Failed: #{notification.failed}"

And that's it!

For more detailed examples:

  1. Apple iOS example
  2. Google GCM example
  3. Windows Phone example (thanks @lazaronixon)

Find more