apns_simple 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/apns_simple/notification.rb +28 -8
- data/lib/apns_simple/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8deda36c16dcb9ad3c41e424a1287ff60eb8a697
|
4
|
+
data.tar.gz: c97fb5afd36ac51258a296e92db15fe892f3ef95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74e50f9fc9ec6318efba324e28cb91b516328afc705919fba338ccc53caf8bf87e9654ccf9e9fb9cbb8e13cc483412956646edced509ede5729ef465bb33dd54
|
7
|
+
data.tar.gz: 744fa284a241194ae723b5540088dfbdda41e385dd38fb23447141e1c6aee312e7a9b10aec47ff548234b9636264b242f0cf0bf495c35a01ce74eacfd7db0102
|
@@ -22,17 +22,37 @@ module ApnsSimple
|
|
22
22
|
payload_hash[:aps]['content-available'] = 1 if content_available
|
23
23
|
payload_hash.merge! custom_payload
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
token_item = pack_token_item(token)
|
26
|
+
payload_item = pack_payload_item(payload_hash)
|
27
|
+
frame = compose_frame(token_item, payload_item)
|
28
|
+
@payload = pack_frame(frame)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
self.error_message = "Payload size is #{payload_size} bytes but maximum #{PAYLOAD_MAX_BYTESIZE} bytes allowed."
|
33
|
+
def pack_frame(frame)
|
34
|
+
[2, frame.bytesize, frame].pack('cNa*')
|
32
35
|
end
|
33
36
|
|
34
|
-
|
35
|
-
|
37
|
+
def compose_frame(*args)
|
38
|
+
args.compact.join
|
39
|
+
end
|
40
|
+
|
41
|
+
def pack_token_item(token)
|
42
|
+
[1, 32, token.gsub(/[<\s>]/, '')].pack('cnH64')
|
43
|
+
end
|
44
|
+
|
45
|
+
def pack_payload_item(hash)
|
46
|
+
json = hash.to_json.gsub(/\\u([\da-fA-F]{4})/) { |m| [$1].pack('H*').unpack('n*').pack('U*') }
|
47
|
+
size = json.bytesize
|
48
|
+
|
49
|
+
if size > PAYLOAD_MAX_BYTESIZE
|
50
|
+
self.error = true
|
51
|
+
self.error_message = "Payload size is #{size} bytes but maximum #{PAYLOAD_MAX_BYTESIZE} bytes allowed."
|
52
|
+
end
|
53
|
+
|
54
|
+
[2, size, json].pack('cna*')
|
55
|
+
end
|
36
56
|
|
37
57
|
end
|
38
58
|
end
|
data/lib/apns_simple/version.rb
CHANGED