black_berry_push 0.0.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 +15 -0
- data/lib/push.rb +64 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MmZiMGIxN2I3ZDdjOWNmM2JlMGNmYzkwOWFkNGZkNzgzOTY3ZDhhZg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MDJkZDA0MWFhZTRmMjg2Y2YwMmJiNTkzNjg5MzI0YTRlMmFmZTBiNw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MWU1NzMxMjdhMjAzYWRjNjY4ZTY2OWMwNzg3YjVkYzI2ODViNjA2ZTg4Zjcz
|
10
|
+
ZDRmMGM2OWJlZGIyODYwMmY2ZjliZTU1ZjAzNjYwMjE2MWUyYjc1M2ViYmQz
|
11
|
+
Nzk2NWM2NWMyYTcyZjhjNDYzYTk2OTU2ODYzNjFmYzEzZjJhMDg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MjQ1YmE0ZWMzMTcyM2NjOTY2MGJlZDQ2YjRiNzgxNjMwNWVlYjhkZDMxODE3
|
14
|
+
MmRmMzE3NzMyOGE0NzZhOGRiZDQ0ZjRlNDA3MTY0MmQyMmY1OGJlNjQxZjhj
|
15
|
+
M2U4YmI4NzU1ZGZiYTlkNjk1Y2ZlOTc0OGI2NjBkYjViZjAzYWU=
|
data/lib/push.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'uri'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'restclient'
|
6
|
+
class Push
|
7
|
+
attr_accessor :pin,:content,:push_api_url,:app_id ,:pass
|
8
|
+
attr_reader :boundry,:push_id,:delivery_method,:delivery_before,:content_type
|
9
|
+
def initialize(options={})
|
10
|
+
@app_id = options[:app_id]
|
11
|
+
@pass = options[:pass]
|
12
|
+
@push_api_url = options[:push_api_url]||"https://pushapi.eval.blackberry.com/mss/PD_pushRequest"
|
13
|
+
@pin = options[:pin]
|
14
|
+
@addresses = []
|
15
|
+
@pin.each do |a|
|
16
|
+
@addresses << "<address address-value=\"#{a}\"/>\n"
|
17
|
+
end
|
18
|
+
@content = options[:content]
|
19
|
+
@boundary='fghjkklllmnggddcvjjkkm'
|
20
|
+
@push_id=Time.now.to_i # ID requires to be more than 10 digits
|
21
|
+
@delivery_method='unconfirmed'
|
22
|
+
@t= Time.now+(60*5)
|
23
|
+
@delivery_before=@t.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
|
24
|
+
@content_type="Content-Type: multipart/related; boundary=" + @boundary + "; type=application/xml"
|
25
|
+
send_push
|
26
|
+
end
|
27
|
+
|
28
|
+
def data
|
29
|
+
data="--#{@boundary}
|
30
|
+
Content-Type: application/xml; charset=UTF-8
|
31
|
+
<?xml version='1.0'?>
|
32
|
+
<!DOCTYPE pap PUBLIC '-//WAPFORUM//DTD PAP 2.1//EN' 'http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd'>
|
33
|
+
<pap>
|
34
|
+
<push-message push-id='#{@push_id}' deliver-before-timestamp='#{@delivery_before}' source-reference='#{@app_id}'>
|
35
|
+
#{@addresses.join("\n")}
|
36
|
+
<custome>pinak</custome>
|
37
|
+
<quality-of-service delivery-method='#{@delivery_method}'/>
|
38
|
+
</push-message>
|
39
|
+
</pap>
|
40
|
+
--#{@boundary}
|
41
|
+
Content-Type: text/plain
|
42
|
+
Push-Message-ID:#{@push_id}
|
43
|
+
|
44
|
+
#{@content}
|
45
|
+
--#{@boundary}--"
|
46
|
+
end
|
47
|
+
def send_push
|
48
|
+
response = RestClient::Request.execute(:method => :post,
|
49
|
+
:url =>@push_api_url,
|
50
|
+
:payload => data,
|
51
|
+
:headers=> {
|
52
|
+
:content_type=> @content_type,
|
53
|
+
# :authorization => auth,
|
54
|
+
:user_agent=> "User-Agent: Yuichi@Idea BB Push Server/1.0"
|
55
|
+
},
|
56
|
+
:user=> @app_id,
|
57
|
+
:password=> @pass
|
58
|
+
)
|
59
|
+
|
60
|
+
puts data
|
61
|
+
puts response.code
|
62
|
+
puts response
|
63
|
+
end
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: black_berry_push
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pinak Thakkar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Usefull for sending push notification to blackberry devices
|
14
|
+
email:
|
15
|
+
- pinak@complitech.net
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/push.rb
|
21
|
+
homepage:
|
22
|
+
licenses: []
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.0.3
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: BlackBerry Push notification
|
44
|
+
test_files: []
|