xmpush 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1152b540182d3c686bd408815b2aaa26f485ece6
4
- data.tar.gz: 3ff89e4b902db18baea56fd54f7cd59e99693500
3
+ metadata.gz: db8c672e180cd6677a2d924c5c7bf2390768d7d9
4
+ data.tar.gz: ded56f01305c94545bc3ff5cefdec06c98bd3a23
5
5
  SHA512:
6
- metadata.gz: 8d2bcd10bb02a846c231be79db55ca8c726102bab59c5c64375ac4e74f4ec8c42297e275b097c98b96977185bab4fde057883de648d88a76ea97510c9c76c8f5
7
- data.tar.gz: 7fac5cc8c2a0af1fb7c4c08190aac34d691e15a21c476dd454af716f9eec4212b765791ab1ea5877dc18e2c5702de0e9acfcb65110017a3ac785a51d0d3ff1e8
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
- # @extra = {sound_url: sound_url, badge: badge}
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Xmpush
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
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
- else
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
- else #:all
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 = @sandbox ? Xmpush::XmResource::SANDBOX_DOMAIN : Xmpush::XmResource::OFFICIAL_DOMAIN
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xmpush
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - blackanger