From ac0b884f8db73a9261c85554b11001f79f32b380 Mon Sep 17 00:00:00 2001 From: dimagoltsman Date: Mon, 25 Aug 2014 14:25:29 +0300 Subject: [PATCH 1/2] adding iOS 8 category support --- README.md | 12 ++++++------ lib/pushmeup/apns/notification.rb | 4 +++- lib/pushmeup/version.rb | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9adcf4e..724996f 100644 --- a/README.md +++ b/README.md @@ -59,13 +59,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 @@ -80,11 +80,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]) ... @@ -94,12 +94,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 diff --git a/lib/pushmeup/apns/notification.rb b/lib/pushmeup/apns/notification.rb index 60d76f6..fdb909d 100644 --- a/lib/pushmeup/apns/notification.rb +++ b/lib/pushmeup/apns/notification.rb @@ -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 @@ -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 @@ -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 diff --git a/lib/pushmeup/version.rb b/lib/pushmeup/version.rb index 8d944ed..7309bfe 100644 --- a/lib/pushmeup/version.rb +++ b/lib/pushmeup/version.rb @@ -1,3 +1,3 @@ module Pushmeup - VERSION = "0.3.0" + VERSION = "0.4.0" end From 815b2b0bc3f5dcef7886cbe39b1107e2b0ed4ec8 Mon Sep 17 00:00:00 2001 From: Rami Gluzman Date: Sun, 27 Dec 2015 14:53:30 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 724996f..36e01fb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +** DEPRECATED ** + # Pushmeup ### a gem for various push notification services.