Class: RubyPushNotifications::FCM::FCMConnection
- Inherits:
-
Object
- Object
- RubyPushNotifications::FCM::FCMConnection
- Defined in:
- lib/ruby-push-notifications/fcm/fcm_connection.rb
Overview
Encapsulates a connection to the FCM service Responsible for final connection with the service.
Constant Summary collapse
- FCM_URL =
'https://fcm.googleapis.com/fcm'- CONTENT_TYPE_HEADER =
'Content-Type'- JSON_CONTENT_TYPE =
'application/json'- AUTHORIZATION_HEADER =
'Authorization'- GROUP_NOTIFICATION_BASE_URI =
'https://android.googleapis.com/gcm'
Class Method Summary collapse
-
.post(notification, key) ⇒ FCMResponse
Issues a POST request to the FCM send endpoint to submit the given notifications.
Class Method Details
.post(notification, key) ⇒ FCMResponse
Issues a POST request to the FCM send endpoint to submit the given notifications.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ruby-push-notifications/fcm/fcm_connection.rb', line 36 def self.post(notification, key) headers = { CONTENT_TYPE_HEADER => JSON_CONTENT_TYPE, AUTHORIZATION_HEADER => "key=#{key}" } # TODO: remove to_json if causing error params = { body: notification, headers: { AUTHORIZATION_HEADER => "key=#{key}", CONTENT_TYPE_HEADER => JSON_CONTENT_TYPE } } fcm_request = FCMRequest.new(params) response = fcm_request.make_request # puts '*' * 10 # puts response # puts '*' * 10 FCMResponse.new response.code.to_i, response.body end |