xmpush 0.0.5 → 0.0.6
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/README.md +1 -2
- data/lib/xmpush/android_builder.rb +23 -4
- data/lib/xmpush/ios_builder.rb +1 -1
- data/lib/xmpush/version.rb +1 -1
- data/lib/xmpush.rb +4 -4
- 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: db8c672e180cd6677a2d924c5c7bf2390768d7d9
|
4
|
+
data.tar.gz: ded56f01305c94545bc3ff5cefdec06c98bd3a23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72b641199e4f4e369d83b3aef4b961358cc6a6088f618291bd633fe7880048d79bc8448955695adaa7dbfac680c1068e1943d33612cb603580fdb7d617e69737
|
7
|
+
data.tar.gz: b725b9917583a1e16e758629f35fd23b55c450dedb7fdd7f3e1f0857af6561c5d990faca3d83980b07293dfa3b43042a62aa3eb35dc72234030b7cc9cba7d295
|
data/README.md
CHANGED
@@ -35,13 +35,12 @@ end
|
|
35
35
|
@xm_service.push(:alias, @message2, alias: '1043478')
|
36
36
|
|
37
37
|
# iOS and Android
|
38
|
-
@message3 = @xm_service.build(description: 'push to iOS and Android client')
|
38
|
+
@message3 = @xm_service.build(:both, title: "I'm title", description: 'push to iOS and Android client')
|
39
39
|
@xm_service.push(:all, @message3)
|
40
40
|
|
41
41
|
```
|
42
42
|
|
43
43
|
## TODO
|
44
44
|
|
45
|
-
- Android push
|
46
45
|
- Multi push
|
47
46
|
- Feedback/ Stats/ Tracer/ Targeted_message
|
@@ -10,13 +10,32 @@ module Xmpush
|
|
10
10
|
NTF_CENTER_NTF = 0 # 通知栏消息
|
11
11
|
PASS_THROUGH_NTF = 1 # 透传消息
|
12
12
|
|
13
|
-
attr_accessor :pass_through, :notify_id
|
13
|
+
attr_accessor :pass_through, :notify_id, :sound_url
|
14
14
|
|
15
15
|
def initialize(**message)
|
16
|
-
@pass_through = message.delete(:pass_through) || 0
|
17
|
-
@notify_id = message.delete(:notify_id) || 0
|
18
16
|
super(message)
|
19
|
-
|
17
|
+
extra = message.delete(:extra) if message[:extra]
|
18
|
+
@pass_through = message[:pass_through] || NTF_CENTER_NTF
|
19
|
+
@notify_id = message[:notify_id] || 0
|
20
|
+
@notify_type = message[:notify_type] || NOTIFY_TYPE_DEFAULT_ALL
|
21
|
+
extra_message = {sound_url: ""}
|
22
|
+
extra_message.merge!(extra) if extra
|
23
|
+
@extra = extra_message
|
24
|
+
end
|
25
|
+
|
26
|
+
def build
|
27
|
+
extra_message = extra(@extra) if @extra
|
28
|
+
message = {
|
29
|
+
payload: @payload,
|
30
|
+
title: @title,
|
31
|
+
notify_id: @notify_id,
|
32
|
+
pass_through: @pass_through,
|
33
|
+
notify_type: @notify_type,
|
34
|
+
restricted_package_name: @restricted_package_name,
|
35
|
+
description: @description
|
36
|
+
}
|
37
|
+
message.merge!(extra_message)
|
38
|
+
return message
|
20
39
|
end
|
21
40
|
|
22
41
|
end
|
data/lib/xmpush/ios_builder.rb
CHANGED
@@ -3,8 +3,8 @@ module Xmpush
|
|
3
3
|
attr_accessor :sound_url, :badge
|
4
4
|
|
5
5
|
def initialize(**message)
|
6
|
-
extra = message.delete(:extra) if message[:extra]
|
7
6
|
super(message)
|
7
|
+
extra = message.delete(:extra) if message[:extra]
|
8
8
|
extra_message = {sound_url: "", badge: 1}
|
9
9
|
extra_message.merge!(extra) if extra
|
10
10
|
@extra = extra_message
|
data/lib/xmpush/version.rb
CHANGED
data/lib/xmpush.rb
CHANGED
@@ -34,7 +34,7 @@ module Xmpush
|
|
34
34
|
build_message = { ios: ios_builder(message)}
|
35
35
|
when :android
|
36
36
|
build_message = { android: android_builder(message) }
|
37
|
-
|
37
|
+
when :both
|
38
38
|
build_message = { ios: ios_builder(message), android: android_builder(message)}
|
39
39
|
end
|
40
40
|
return build_message
|
@@ -54,7 +54,7 @@ module Xmpush
|
|
54
54
|
return "must input topic" unless options[:topic]
|
55
55
|
message.values.each{|v| v.merge!(topic: options[:topic])}
|
56
56
|
resource_post('topic', message)
|
57
|
-
|
57
|
+
when :all
|
58
58
|
resource_post('all', message)
|
59
59
|
end
|
60
60
|
end
|
@@ -77,8 +77,8 @@ module Xmpush
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def android_http
|
80
|
-
return "android don't support sandbox" if @sandbox
|
81
|
-
host =
|
80
|
+
# return "android don't support sandbox" if @sandbox
|
81
|
+
host = Xmpush::XmResource::OFFICIAL_DOMAIN
|
82
82
|
Xmpush::HttpBase.new(host, @android_secret, @connection_adapter)
|
83
83
|
end
|
84
84
|
|