Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
** DEPRECATED **

# Pushmeup

### a gem for various push notification services.
Expand Down Expand Up @@ -59,13 +61,13 @@ and install it with

device_token = '123abc456def'
APNS.send_notification(device_token, 'Hello iPhone!' )
APNS.send_notification(device_token, :alert => 'Hello iPhone!', :badge => 1, :sound => 'default')
APNS.send_notification(device_token, :alert => 'Hello iPhone!', :badge => 1, :sound => 'default', :category => 'cat1')

#### Sending multiple notifications

device_token = '123abc456def'
n1 = APNS::Notification.new(device_token, 'Hello iPhone!' )
n2 = APNS::Notification.new(device_token, :alert => 'Hello iPhone!', :badge => 1, :sound => 'default')
n2 = APNS::Notification.new(device_token, :alert => 'Hello iPhone!', :badge => 1, :sound => 'default', :category => 'cat1')
APNS.send_notifications([n1, n2])

> All notifications passed as a parameter will be sent on a single connection, this is done to improve
Expand All @@ -80,11 +82,11 @@ and install it with

# Send single notifications
APNS.send_notification(device_token, 'Hello iPhone!' )
APNS.send_notification(device_token, :alert => 'Hello iPhone!', :badge => 1, :sound => 'default')
APNS.send_notification(device_token, :alert => 'Hello iPhone!', :badge => 1, :sound => 'default', :category => 'cat1')

# Send multiple notifications
n1 = APNS::Notification.new(device_token, 'Hello iPhone!' )
n2 = APNS::Notification.new(device_token, :alert => 'Hello iPhone!', :badge => 1, :sound => 'default')
n2 = APNS::Notification.new(device_token, :alert => 'Hello iPhone!', :badge => 1, :sound => 'default', :category => 'cat1')
APNS.send_notifications([n1, n2])

...
Expand All @@ -94,12 +96,12 @@ and install it with

#### Sending more information along

APNS.send_notification(device_token, :alert => 'Hello iPhone!', :badge => 1, :sound => 'default',
APNS.send_notification(device_token, :alert => 'Hello iPhone!', :badge => 1, :sound => 'default', :category => 'cat1',
:other => {:sent => 'with apns gem', :custom_param => "value"})

this will result in a payload like this:

{"aps":{"alert":"Hello iPhone!","badge":1,"sound":"default"},"sent":"with apns gem", "custom_param":"value"}
{"aps":{"alert":"Hello iPhone!","badge":1,"sound":"default", "category":"cat1"},"sent":"with apns gem", "custom_param":"value"}

### Getting your iOS device token

Expand Down
4 changes: 3 additions & 1 deletion lib/pushmeup/apns/notification.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module APNS
class Notification
attr_accessor :device_token, :alert, :badge, :sound, :other
attr_accessor :device_token, :alert, :badge, :sound, :category, :other

def initialize(device_token, message)
self.device_token = device_token
Expand All @@ -9,6 +9,7 @@ def initialize(device_token, message)
self.badge = message[:badge]
self.sound = message[:sound]
self.other = message[:other]
self.category = message[:category]
elsif message.is_a?(String)
self.alert = message
else
Expand All @@ -31,6 +32,7 @@ def packaged_message
aps['aps']['alert'] = self.alert if self.alert
aps['aps']['badge'] = self.badge if self.badge
aps['aps']['sound'] = self.sound if self.sound
aps['aps']['category'] = self.category if self.category
aps.merge!(self.other) if self.other
aps.to_json.gsub(/\\u([\da-fA-F]{4})/) {|m| [$1].pack("H*").unpack("n*").pack("U*")}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pushmeup/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Pushmeup
VERSION = "0.3.0"
VERSION = "0.4.0"
end