我使用FCM提供远程通知,在rails上使用ruby作为api执行推送通知,使用ResClient执行http请求(也尝试过HttpParty)。但它得到了这个错误:
RestClient::RequestTimeout: Request Timeout
from /Users/dowicz/.rvm/gems/ruby-2.3.3/gems/rest-client-1.8.0/lib/restclient/request.rb:427:in `rescue in transmit'
这是我发帖的地方:
def self.send_with_notification_key(options = {})
fmc_url = "https://fcm.googleapis.com/fcm/send"
api_key = ENV['FIREBASE_FCM_API_KEY']
notification_key = [push_key]
options = {priority: "normal", content_available: true, notification: {title: "teste", body: "teste213123" } }
headers = {
'Authorization' => "key=#{api_key}",
'Content-Type' => 'application/json'
}
body = { to: notification_key }.merge(options)
params = { body: body.to_json }
response = RestClient.post(fmc_url, params, headers)
build_response(response)
end
还有其他服务作为创建用户,哪个工作正常..有什么建议吗? 提前谢谢!