Skip to content

Commit 046c515

Browse files
committed
api for sending notifications based on http v1 protocol
1 parent 0f10803 commit 046c515

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
module Fcm
4+
class ClientV1
5+
# Handle notification delivery methods
6+
module NotificationDilivery
7+
BASE_URI_V1 = 'https://fcm.googleapis.com/v1/projects/'
8+
TOKEN_URI = 'https://www.googleapis.com/auth/firebase.messaging'
9+
10+
def send_notification_v1(message, project_name)
11+
return if project_name.empty?
12+
13+
post_body = { 'message': message }
14+
end_point = "#{project_name}/messages:send"
15+
16+
res = make_request(
17+
:post, BASE_URI_V1, end_point, post_body, authorization_headers
18+
)
19+
Fcm::Response.build_fcm_response(res)
20+
end
21+
end
22+
end
23+
end

0 commit comments

Comments
 (0)