File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 1
- gem " exponent-server-sdk"
1
+ gem ' exponent-server-sdk' , git : 'https://github.com/gtt-project/expo-server-sdk-ruby.git' , tag : 'v0.1.0-dev1'
Original file line number Diff line number Diff line change @@ -17,9 +17,9 @@ def add_recipient(user)
17
17
@recipients << user
18
18
end
19
19
20
- # https://docs.expo.io/versions/latest/guides/ push-notifications/
20
+ # https://docs.expo.io/push-notifications/sending -notifications/
21
21
# https://github.com/expo/expo-server-sdk-ruby
22
- # https://docs.expo.io/versions/latest/guides/ push-notifications/#message-format
22
+ # https://docs.expo.io/push-notifications/sending-notifications/ #message-request -format
23
23
def deliver
24
24
messages = @recipients . map do |user |
25
25
ExpoPushToken . where ( user : user ) . map do |token |
@@ -34,11 +34,19 @@ def deliver
34
34
messages . flatten!
35
35
36
36
if messages . any?
37
- begin
38
- Exponent ::Push ::Client . new ( gzip : true ) . send_messages messages
39
- rescue Exception
40
- Rails . logger . error "error sending push notifications:\n #{ $!} \n " + $!. backtrace . join ( "\n " )
41
- end
37
+ messages . each_slice ( 100 ) { |message_list |
38
+ begin
39
+ handler = Exponent ::Push ::Client . new ( gzip : true ) . send_messages message_list
40
+ if handler . errors . present?
41
+ Rails . logger . error "handler.errors:#{ handler . errors } "
42
+ end
43
+ if handler . receipt_ids . present?
44
+ Rails . logger . info "handler.receipt_ids:#{ handler . receipt_ids } "
45
+ end
46
+ rescue Exception
47
+ Rails . logger . error "error sending push notifications:\n #{ $!} \n " + $!. backtrace . join ( "\n " )
48
+ end
49
+ }
42
50
end
43
51
end
44
52
end
You can’t perform that action at this time.
0 commit comments