Class: Expo::Push::Middleware::Client
- Inherits:
-
Object
- Object
- Expo::Push::Middleware::Client
- Defined in:
- lib/expo-push-middleware.rb
Defined Under Namespace
Classes: Error, TooManyMessagesError
Instance Method Summary collapse
-
#initialize(**args) ⇒ Client
constructor
A new instance of Client.
- #send_messages(messages, **_) ⇒ Object
Constructor Details
#initialize(**args) ⇒ Client
Returns a new instance of Client.
28 29 30 |
# File 'lib/expo-push-middleware.rb', line 28 def initialize(**args) @http_client = args[:http_client] || Typhoeus end |
Instance Method Details
#send_messages(messages, **_) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/expo-push-middleware.rb', line 32 def (, **_) # https://docs.expo.io/versions/latest/guides/push-notifications/#message-format expo_tokens = .map { || .with_indifferent_access[:to] }.flatten raise TooManyMessagesError, "Only 100 message objects at a time allowed." if expo_tokens.length > 100 @http_client.post( "#{Expo::Push::Middleware.config.api_url}/api/v1/push_requests", body: { push_request: { messages: } }.to_json, headers: headers ) end |