pntfr 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pntfr/version.rb +1 -1
- data/lib/pntfr/virtual_session/android.rb +18 -3
- data/lib/pntfr/virtual_session/base.rb +4 -2
- data/lib/pntfr/virtual_session/base_response.rb +31 -0
- data/lib/pntfr/virtual_session/gcm_response.rb +44 -0
- data/lib/pntfr/virtual_session/ios.rb +11 -1
- data/lib/pntfr/virtual_session/success_response.rb +31 -0
- data/pntfr.gemspec +1 -0
- data/test/pntfr/push_notifier_test.rb +0 -36
- data/test/pntfr/virtual_session/android_test.rb +48 -0
- data/test/pntfr/{ios_badge_test.rb → virtual_session/ios_badge_test.rb} +0 -0
- data/test/pntfr/virtual_session/ios_test.rb +43 -0
- data/test/pntfr/virtual_session/response_test.rb +49 -0
- metadata +27 -10
- data/nbproject/private/private.properties +0 -2
- data/nbproject/private/rake-d.txt +0 -5
- data/nbproject/project.properties +0 -7
- data/nbproject/project.xml +0 -15
- data/test/pntfr/ios_test.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f3b8477063d23af20f997756ac2525bd3b32780
|
4
|
+
data.tar.gz: 5f1680126704e0ebca33794342a03a96a471ab9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4587cc3c9d9e1fc1707813312c914b10ae80bf849a9e56d3c2f2651fd31e8b2174fa404cfa9fa5b34cbc48b2cd28e2d003eda718f5aaf5c0914a42bd5eddee88
|
7
|
+
data.tar.gz: 5958abd16c317ca5eaf9b748b4fb8df87c4665208b4a9a9bd3b3422d0b88b2e3601820ca16020315e43e356616505cf4f8546d29efecf08966069d9bae7ce7c2
|
data/lib/pntfr/version.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
#
|
2
2
|
# VirtualSession implementation for Android
|
3
3
|
#
|
4
|
-
|
4
|
+
require 'gcm'
|
5
5
|
module Pntfr
|
6
6
|
module VirtualSession
|
7
7
|
class Android < Pntfr::VirtualSession::Base
|
8
|
+
FILE_EXTENSION_REGEXP= /(\.[^\.]+)\z/
|
9
|
+
|
8
10
|
def initialize session
|
9
11
|
super
|
10
12
|
@notification_key= Pntfr.config.gcm[:notification_key]
|
11
|
-
@gcm= GCM.new(@notification_key) unless Pntfr.test_env?
|
13
|
+
@gcm= ::GCM.new(@notification_key) unless Pntfr.test_env?
|
12
14
|
end
|
13
15
|
|
14
16
|
def msg content
|
@@ -16,17 +18,30 @@ module Pntfr
|
|
16
18
|
:title => content[:title],
|
17
19
|
:description => content[:description],
|
18
20
|
}
|
21
|
+
@data[:sound]= parse_sound_file(content[:sound]) unless content[:sound].nil?
|
19
22
|
self
|
20
23
|
end
|
21
24
|
def notify
|
22
25
|
options = {data: @data}
|
23
26
|
if Pntfr.test_env?
|
24
27
|
Pntfr.add_delivery(@push_id, options)
|
28
|
+
VirtualSession::SuccessResponse.new
|
25
29
|
else
|
26
|
-
@gcm.send_notification(@push_id, options)
|
30
|
+
rs= @gcm.send_notification([@push_id], options)
|
31
|
+
parse_response rs
|
27
32
|
end
|
28
33
|
end
|
29
34
|
|
35
|
+
#---------------------------------------------------------
|
36
|
+
private
|
37
|
+
#---------------------------------------------------------
|
38
|
+
def parse_response rs
|
39
|
+
VirtualSession::GcmResponse.new(rs)
|
40
|
+
end
|
41
|
+
|
42
|
+
def parse_sound_file filename
|
43
|
+
filename.gsub(FILE_EXTENSION_REGEXP, '')
|
44
|
+
end
|
30
45
|
end
|
31
46
|
end
|
32
47
|
end
|
@@ -11,5 +11,7 @@ module Pntfr
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
|
-
require
|
15
|
-
require
|
14
|
+
require 'pntfr/virtual_session/success_response'
|
15
|
+
require 'pntfr/virtual_session/android'
|
16
|
+
require 'pntfr/virtual_session/gcm_response'
|
17
|
+
require 'pntfr/virtual_session/ios'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Pntfr
|
2
|
+
module VirtualSession
|
3
|
+
class BaseResponse
|
4
|
+
# communication with notification service was OK?
|
5
|
+
# implies no +failure?+
|
6
|
+
def success?
|
7
|
+
raise 'not implemented!'
|
8
|
+
end
|
9
|
+
# message has been sent?
|
10
|
+
def msg_sent?
|
11
|
+
raise 'not implemented!'
|
12
|
+
end
|
13
|
+
# communication with notification service failed?
|
14
|
+
# implies no +succcess?+
|
15
|
+
def failure?
|
16
|
+
raise 'not implemented!'
|
17
|
+
end
|
18
|
+
# Was there an error with the notification?
|
19
|
+
# implies +succcess?+ but no +msg_sent?+
|
20
|
+
def error?
|
21
|
+
raise 'not implemented!'
|
22
|
+
end
|
23
|
+
# which was the error?
|
24
|
+
def error
|
25
|
+
end
|
26
|
+
# which was the failure?
|
27
|
+
def failure
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# Google Cloud Messaging json response wrapper.
|
3
|
+
#
|
4
|
+
require 'pntfr/virtual_session/base_response'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
module Pntfr
|
8
|
+
module VirtualSession
|
9
|
+
class GcmResponse < BaseResponse
|
10
|
+
def initialize json
|
11
|
+
@status_code= json[:status_code]
|
12
|
+
@response= json[:response]
|
13
|
+
@body= json[:body]
|
14
|
+
if success?
|
15
|
+
@parsed_body= JSON.parse(@body)
|
16
|
+
@body_result= @parsed_body['results'].first
|
17
|
+
end
|
18
|
+
end
|
19
|
+
def success?
|
20
|
+
@status_code == 200
|
21
|
+
end
|
22
|
+
def bad_sender_account?
|
23
|
+
@status_code == 401
|
24
|
+
end
|
25
|
+
def failure?
|
26
|
+
@status_code == 400 or @status_code >= 500
|
27
|
+
end
|
28
|
+
def msg_sent?
|
29
|
+
success? && @parsed_body['success'] == 1
|
30
|
+
end
|
31
|
+
def error?
|
32
|
+
success? and !msg_sent? and @body_result.has_key?('error')
|
33
|
+
end
|
34
|
+
def error
|
35
|
+
if error?
|
36
|
+
@body_result['error']
|
37
|
+
end
|
38
|
+
end
|
39
|
+
def failure
|
40
|
+
"#{@body}->#{@response}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
#
|
2
2
|
# VirtualSession implementation for iOS
|
3
3
|
#
|
4
|
+
require 'apns'
|
4
5
|
module Pntfr
|
5
6
|
module VirtualSession
|
6
7
|
class Ios < Pntfr::VirtualSession::Base
|
7
8
|
def msg content
|
9
|
+
configure_apns
|
8
10
|
reset_msg
|
9
11
|
@alert= content[:title]
|
10
12
|
@alert+= "\n#{content[:description]}"
|
@@ -27,14 +29,22 @@ module Pntfr
|
|
27
29
|
if Pntfr.test_env?
|
28
30
|
Pntfr.add_delivery(@push_id, n)
|
29
31
|
else
|
30
|
-
APNS.send_notification(@push_id, n)
|
32
|
+
::APNS.send_notification(@push_id, n)
|
31
33
|
end
|
34
|
+
SuccessResponse.new
|
32
35
|
end
|
33
36
|
|
34
37
|
#-------------------------------------------------
|
35
38
|
private
|
36
39
|
#-------------------------------------------------
|
37
40
|
|
41
|
+
def configure_apns
|
42
|
+
config= Pntfr.config.apns
|
43
|
+
APNS.host = config[:host]
|
44
|
+
APNS.pem = config[:pem]
|
45
|
+
APNS.port = config[:port]
|
46
|
+
APNS.pass = config[:pass]
|
47
|
+
end
|
38
48
|
def reset_msg
|
39
49
|
@alert= @sound= @badge= nil
|
40
50
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# Always success.
|
3
|
+
# To be used on cases where no response to be parsed is received.
|
4
|
+
#
|
5
|
+
require 'pntfr/virtual_session/base_response'
|
6
|
+
|
7
|
+
module Pntfr
|
8
|
+
module VirtualSession
|
9
|
+
class SuccessResponse < BaseResponse
|
10
|
+
# communication with notification service was OK?
|
11
|
+
# implies no +failure?+
|
12
|
+
def success?
|
13
|
+
true
|
14
|
+
end
|
15
|
+
# message has been sent?
|
16
|
+
def msg_sent?
|
17
|
+
true
|
18
|
+
end
|
19
|
+
# communication with notification service failed?
|
20
|
+
# implies no +succcess?+
|
21
|
+
def failure?
|
22
|
+
false
|
23
|
+
end
|
24
|
+
# Was there an error with the notification?
|
25
|
+
# implies +succcess?+ but no +msg_sent?+
|
26
|
+
def error?
|
27
|
+
false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/pntfr.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency 'apns', '~> 1.0', '>= 1.0.0'
|
22
22
|
spec.add_runtime_dependency 'gcm', '~> 0.0', '>= 0.0.9'
|
23
|
+
spec.add_runtime_dependency 'json', '~> 1.8.1'
|
23
24
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
24
25
|
spec.add_development_dependency 'rake'
|
25
26
|
end
|
@@ -6,9 +6,6 @@ module Pntfr
|
|
6
6
|
Pntfr.configure {}
|
7
7
|
end
|
8
8
|
|
9
|
-
#
|
10
|
-
# COMMON
|
11
|
-
#
|
12
9
|
def test_android_sessions_should_instantiate_android_virtual_sessions
|
13
10
|
session= DeviceSession.new(Pntfr::Platforms::ANDROID)
|
14
11
|
vsess= Pntfr::Notifier.to(session)
|
@@ -20,38 +17,5 @@ module Pntfr
|
|
20
17
|
assert vsess.is_a?(Pntfr::VirtualSession::Ios)
|
21
18
|
end
|
22
19
|
|
23
|
-
#
|
24
|
-
# ANDROID
|
25
|
-
#
|
26
|
-
def test_received_content_shoud_be_sent_to_gcm
|
27
|
-
push_id= 'ANDROIDANDROIDANDROIDANDROIDANDROIDANDROIDANDROIDANDROIDANDROID'
|
28
|
-
session= DeviceSession.new(Pntfr::Platforms::ANDROID, push_id)
|
29
|
-
|
30
|
-
Pntfr::Notifier.to(session).msg({:title => 'Some Title', :description => 'A description'}).notify
|
31
|
-
|
32
|
-
notifs= Pntfr.deliveries[push_id]
|
33
|
-
refute_nil notifs, "A notification should have been delivered for #{push_id}"
|
34
|
-
notif= notifs.last
|
35
|
-
assert_equal "Some Title", notif[:data][:title]
|
36
|
-
assert_equal "A description", notif[:data][:description]
|
37
|
-
end
|
38
|
-
|
39
|
-
#
|
40
|
-
# IOS
|
41
|
-
#
|
42
|
-
def test_received_content_shoud_be_ready_to_be_sent_to_apns
|
43
|
-
push_id= 'IOSiosIOSiosIOSiosIOSiosIOSiosIOSiosIOSiosIOSiosIOSiosIOSios'
|
44
|
-
session= DeviceSession.new(Pntfr::Platforms::IOS, push_id)
|
45
|
-
|
46
|
-
Pntfr::Notifier.to(session).msg({:title => 'thatitle', :description => 'thadescription', :sound => 'click.aiff', :badge => 33}).notify
|
47
|
-
|
48
|
-
ios_notifs= Pntfr.deliveries[push_id]
|
49
|
-
refute_nil ios_notifs, "A notification should have been delivered for #{push_id}"
|
50
|
-
ios_notif= ios_notifs.last
|
51
|
-
assert_equal "thatitle\nthadescription", ios_notif[:alert]
|
52
|
-
assert_equal 'click.aiff', ios_notif[:sound]
|
53
|
-
assert_equal 33, ios_notif[:badge]
|
54
|
-
end
|
55
|
-
|
56
20
|
end
|
57
21
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'pntfr/device_session'
|
2
|
+
module Pntfr
|
3
|
+
module VirtualSession
|
4
|
+
class AndroidTest < Minitest::Test
|
5
|
+
def initialize method_name
|
6
|
+
super
|
7
|
+
Pntfr.configure {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_received_content_shoud_be_sent_to_gcm
|
11
|
+
push_id= 'ANDROIDANDROIDANDROIDANDROIDANDROIDANDROIDANDROIDANDROIDANDROID'
|
12
|
+
session= DeviceSession.new(Pntfr::Platforms::ANDROID, push_id)
|
13
|
+
|
14
|
+
vsession= Pntfr::Notifier.to(session).msg({
|
15
|
+
:title => 'Some Title', :description => 'A description',
|
16
|
+
:sound => 'bell.caff'
|
17
|
+
})
|
18
|
+
rs= vsession.notify
|
19
|
+
assert rs.success? and rs.msg_sent?
|
20
|
+
|
21
|
+
notifs= Pntfr.deliveries[push_id]
|
22
|
+
refute_nil notifs, "A notification should have been delivered for #{push_id}"
|
23
|
+
notif= notifs.last
|
24
|
+
assert_equal 'Some Title', notif[:data][:title]
|
25
|
+
assert_equal 'A description', notif[:data][:description]
|
26
|
+
assert_equal 'bell', notif[:data][:sound]
|
27
|
+
end
|
28
|
+
def test_sound_attribute_shoud_be_sent_to_gcm
|
29
|
+
push_id= 'ANDROIDANDROIDANDROIDANDROIDANDROIDANDROIDANDROIDANDROIDANDROID'
|
30
|
+
session= DeviceSession.new(Pntfr::Platforms::ANDROID, push_id)
|
31
|
+
|
32
|
+
vsession= Pntfr::Notifier.to(session).msg({
|
33
|
+
:title => 'Some Title', :description => 'A description',
|
34
|
+
:sound => 'bell.caff'
|
35
|
+
})
|
36
|
+
rs= vsession.notify
|
37
|
+
assert rs.success? and rs.msg_sent?
|
38
|
+
|
39
|
+
notifs= Pntfr.deliveries[push_id]
|
40
|
+
refute_nil notifs, "A notification should have been delivered for #{push_id}"
|
41
|
+
notif= notifs.last
|
42
|
+
assert_equal 'Some Title', notif[:data][:title]
|
43
|
+
assert_equal 'A description', notif[:data][:description]
|
44
|
+
assert_equal 'bell', notif[:data][:sound]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'pntfr/device_session'
|
2
|
+
module Pntfr
|
3
|
+
module VirtualSession
|
4
|
+
class IosTest < Minitest::Test
|
5
|
+
def test_received_content_shoud_be_ready_to_be_sent_to_apns
|
6
|
+
push_id= 'IOSiosIOSiosIOSiosIOSiosIOSiosIOSiosIOSiosIOSiosIOSiosIOSios'
|
7
|
+
session= DeviceSession.new(Pntfr::Platforms::IOS, push_id)
|
8
|
+
|
9
|
+
rs= Pntfr::Notifier.to(session).msg({:title => 'thatitle', :description => 'thadescription', :sound => 'click.aiff', :badge => 33}).notify
|
10
|
+
assert rs.success? and rs.msg_sent?
|
11
|
+
|
12
|
+
ios_notifs= Pntfr.deliveries[push_id]
|
13
|
+
refute_nil ios_notifs, "A notification should have been delivered for #{push_id}"
|
14
|
+
ios_notif= ios_notifs.last
|
15
|
+
assert_equal "thatitle\nthadescription", ios_notif[:alert]
|
16
|
+
assert_equal 'click.aiff', ios_notif[:sound]
|
17
|
+
assert_equal 33, ios_notif[:badge]
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_ios_information_from_previous_msg_should_be_reset_when_sending_a_new_msg
|
21
|
+
session= IosDeviceSession.new(Pntfr::Platforms::IOS, name, 3)
|
22
|
+
vsession= Pntfr::Notifier.to(session)
|
23
|
+
|
24
|
+
rs= vsession.msg(title: 't1', description: 'd1', sound: 's1').notify
|
25
|
+
assert rs.success? and rs.msg_sent?
|
26
|
+
rs= vsession.msg(title: 't2', description: 'd2').notify
|
27
|
+
assert rs.success? and rs.msg_sent?
|
28
|
+
|
29
|
+
notifs= Pntfr.deliveries[session.push_id]
|
30
|
+
assert_equal 5, session.num_notifs
|
31
|
+
assert_equal 2, notifs.size
|
32
|
+
notif= notifs.first
|
33
|
+
assert_equal "t1\nd1", notif[:alert]
|
34
|
+
assert_equal 's1', notif[:sound]
|
35
|
+
assert_equal 4, notif[:badge]
|
36
|
+
notif= notifs.last
|
37
|
+
assert_equal "t2\nd2", notif[:alert]
|
38
|
+
assert_equal 'default', notif[:sound]
|
39
|
+
assert_equal 5, notif[:badge]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Pntfr
|
2
|
+
class ResponseTest < Minitest::Test
|
3
|
+
#
|
4
|
+
# Success response
|
5
|
+
#
|
6
|
+
def test_success_response_should_have_sent_msg_and_no_error
|
7
|
+
rs= VirtualSession::SuccessResponse.new
|
8
|
+
assert rs.success? and rs.msg_sent?
|
9
|
+
refute rs.error?
|
10
|
+
refute rs.failure?
|
11
|
+
assert_nil rs.error
|
12
|
+
end
|
13
|
+
#
|
14
|
+
# Android response
|
15
|
+
#
|
16
|
+
def test_gcm_200_responses_with_success_should_have_success_and_no_error
|
17
|
+
json= {:body=>"{\"multicast_id\":1020305051281243425,\"success\":1,\"failure\":0,\"canonical_ids\":0,\"results\":[{\"message_id\":\"0:1418221082312345%88882f99f9fd7ecd\"}]}", :headers=>{"content-type"=>["application/json; charset=UTF-8"], "date"=>["Wed, 10 Dec 2014 14:18:02 GMT"], "expires"=>["Wed, 10 Dec 2014 14:18:02 GMT"], "cache-control"=>["private, max-age=0"], "x-content-type-options"=>["nosniff"], "x-frame-options"=>["SAMEORIGIN"], "x-xss-protection"=>["1; mode=block"], "server"=>["GSE"], "alternate-protocol"=>["443:quic,p=0.02"], "connection"=>["close"]}, :status_code=>200, :response=>"success", :canonical_ids=>[], :not_registered_ids=>[]}
|
18
|
+
rs= VirtualSession::GcmResponse.new(json)
|
19
|
+
assert rs.success?
|
20
|
+
refute rs.error?
|
21
|
+
assert_nil rs.error
|
22
|
+
end
|
23
|
+
def test_gcm_200_responses_with_invalid_registration_should_have_failed_and_report_error
|
24
|
+
json= {:body=>"{\"multicast_id\":6867269885611677069,\"success\":0,\"failure\":1,\"canonical_ids\":0,\"results\":[{\"error\":\"InvalidRegistration\"}]}", :headers=>{"content-type"=>["application/json; charset=UTF-8"], "date"=>["Tue, 09 Dec 2014 21:28:02 GMT"], "expires"=>["Tue, 09 Dec 2014 21:28:02 GMT"], "cache-control"=>["private, max-age=0"], "x-content-type-options"=>["nosniff"], "x-frame-options"=>["SAMEORIGIN"], "x-xss-protection"=>["1; mode=block"], "server"=>["GSE"], "alternate-protocol"=>["443:quic,p=0.02"], "connection"=>["close"]}, :status_code=>200, :response=>"success", :canonical_ids=>[], :not_registered_ids=>[]}
|
25
|
+
rs= VirtualSession::GcmResponse.new(json)
|
26
|
+
refute rs.failure?
|
27
|
+
refute rs.msg_sent?
|
28
|
+
assert rs.success? and rs.error?
|
29
|
+
assert_equal 'InvalidRegistration', rs.error
|
30
|
+
end
|
31
|
+
def test_gcm_200_responses_with_mismatch_sender_id_should_have_failed_and_report_error
|
32
|
+
json= {:body=>"{\"multicast_id\":5372261104801760966,\"success\":0,\"failure\":1,\"canonical_ids\":0,\"results\":[{\"error\":\"MismatchSenderId\"}]}", :headers=>{"content-type"=>["application/json; charset=UTF-8"], "date"=>["Tue, 09 Dec 2014 20:41:01 GMT"], "expires"=>["Tue, 09 Dec 2014 20:41:01 GMT"], "cache-control"=>["private, max-age=0"], "x-content-type-options"=>["nosniff"], "x-frame-options"=>["SAMEORIGIN"], "x-xss-protection"=>["1; mode=block"], "server"=>["GSE"], "alternate-protocol"=>["443:quic,p=0.02"], "connection"=>["close"]}, :status_code=>200, :response=>"success", :canonical_ids=>[], :not_registered_ids=>[]}
|
33
|
+
rs= VirtualSession::GcmResponse.new(json)
|
34
|
+
assert rs.success?
|
35
|
+
refute rs.msg_sent?
|
36
|
+
assert rs.error?
|
37
|
+
refute rs.failure?
|
38
|
+
assert_equal 'MismatchSenderId', rs.error
|
39
|
+
end
|
40
|
+
def test_gcm_400_responses_should_have_failed_and_report_error
|
41
|
+
json= {:body=>"\"registration_ids\" field is not a JSON array\n", :headers=>{"content-type"=>["text/plain; charset=UTF-8"], "date"=>["Tue, 09 Dec 2014 21:27:30 GMT"], "expires"=>["Tue, 09 Dec 2014 21:27:30 GMT"], "cache-control"=>["private, max-age=0"], "x-content-type-options"=>["nosniff"], "x-frame-options"=>["SAMEORIGIN"], "x-xss-protection"=>["1; mode=block"], "server"=>["GSE"], "alternate-protocol"=>["443:quic,p=0.02"], "connection"=>["close"]}, :status_code=>400, :response=>"Only applies for JSON requests. Indicates that the request could not be parsed as JSON, or it contained invalid fields."}
|
42
|
+
rs= VirtualSession::GcmResponse.new(json)
|
43
|
+
refute rs.success? and rs.error?
|
44
|
+
assert rs.failure?
|
45
|
+
expected= "\"registration_ids\" field is not a JSON array\n->Only applies for JSON requests. Indicates that the request could not be parsed as JSON, or it contained invalid fields."
|
46
|
+
assert_equal expected, rs.failure
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pntfr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- oliver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apns
|
@@ -50,6 +50,20 @@ dependencies:
|
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 0.0.9
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: json
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.8.1
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.8.1
|
53
67
|
- !ruby/object:Gem::Dependency
|
54
68
|
name: bundler
|
55
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,17 +111,18 @@ files:
|
|
97
111
|
- lib/pntfr/version.rb
|
98
112
|
- lib/pntfr/virtual_session/android.rb
|
99
113
|
- lib/pntfr/virtual_session/base.rb
|
114
|
+
- lib/pntfr/virtual_session/base_response.rb
|
115
|
+
- lib/pntfr/virtual_session/gcm_response.rb
|
100
116
|
- lib/pntfr/virtual_session/ios.rb
|
101
|
-
-
|
102
|
-
- nbproject/private/rake-d.txt
|
103
|
-
- nbproject/project.properties
|
104
|
-
- nbproject/project.xml
|
117
|
+
- lib/pntfr/virtual_session/success_response.rb
|
105
118
|
- pntfr.gemspec
|
106
119
|
- test/pntfr/device_session.rb
|
107
|
-
- test/pntfr/ios_badge_test.rb
|
108
|
-
- test/pntfr/ios_test.rb
|
109
120
|
- test/pntfr/platforms_test.rb
|
110
121
|
- test/pntfr/push_notifier_test.rb
|
122
|
+
- test/pntfr/virtual_session/android_test.rb
|
123
|
+
- test/pntfr/virtual_session/ios_badge_test.rb
|
124
|
+
- test/pntfr/virtual_session/ios_test.rb
|
125
|
+
- test/pntfr/virtual_session/response_test.rb
|
111
126
|
- test/pntfr_configuration_test.rb
|
112
127
|
- test/test_helper.rb
|
113
128
|
homepage: http://www.coditramuntana.com
|
@@ -137,9 +152,11 @@ summary: Push notifier is a simple adapter for APNS and GCM gems, that way you c
|
|
137
152
|
use same api to send push notifications to both devices.
|
138
153
|
test_files:
|
139
154
|
- test/pntfr/device_session.rb
|
140
|
-
- test/pntfr/ios_badge_test.rb
|
141
|
-
- test/pntfr/ios_test.rb
|
142
155
|
- test/pntfr/platforms_test.rb
|
143
156
|
- test/pntfr/push_notifier_test.rb
|
157
|
+
- test/pntfr/virtual_session/android_test.rb
|
158
|
+
- test/pntfr/virtual_session/ios_badge_test.rb
|
159
|
+
- test/pntfr/virtual_session/ios_test.rb
|
160
|
+
- test/pntfr/virtual_session/response_test.rb
|
144
161
|
- test/pntfr_configuration_test.rb
|
145
162
|
- test/test_helper.rb
|
data/nbproject/project.xml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project xmlns="http://www.netbeans.org/ns/project/1">
|
3
|
-
<type>org.netbeans.modules.ruby.rubyproject</type>
|
4
|
-
<configuration>
|
5
|
-
<data xmlns="http://www.netbeans.org/ns/ruby-project/1">
|
6
|
-
<name>Pntfr</name>
|
7
|
-
<source-roots>
|
8
|
-
<root id="src.dir"/>
|
9
|
-
</source-roots>
|
10
|
-
<test-roots>
|
11
|
-
<root id="test.src.dir"/>
|
12
|
-
</test-roots>
|
13
|
-
</data>
|
14
|
-
</configuration>
|
15
|
-
</project>
|
data/test/pntfr/ios_test.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module Pntfr
|
2
|
-
module VirtualSession
|
3
|
-
class IosTest < Minitest::Test
|
4
|
-
def test_ios_information_from_previous_msg_should_be_reset_when_sending_a_new_msg
|
5
|
-
session= IosDeviceSession.new(Pntfr::Platforms::IOS, name, 3)
|
6
|
-
vsession= Pntfr::Notifier.to(session)
|
7
|
-
|
8
|
-
vsession.msg(title: 't1', description: 'd1', sound: 's1').notify
|
9
|
-
vsession.msg(title: 't2', description: 'd2').notify
|
10
|
-
|
11
|
-
notifs= Pntfr.deliveries[session.push_id]
|
12
|
-
assert_equal 5, session.num_notifs
|
13
|
-
assert_equal 2, notifs.size
|
14
|
-
notif= notifs.first
|
15
|
-
assert_equal "t1\nd1", notif[:alert]
|
16
|
-
assert_equal 's1', notif[:sound]
|
17
|
-
assert_equal 4, notif[:badge]
|
18
|
-
notif= notifs.last
|
19
|
-
assert_equal "t2\nd2", notif[:alert]
|
20
|
-
assert_equal 'default', notif[:sound]
|
21
|
-
assert_equal 5, notif[:badge]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|