我正在尝试使用 FCM gem 向 Android 手机发送推送通知消息。我能够获得设备令牌,并且我认为我按照它应该的方式设置了所有内容。只有当我使用我的 ruby 后端发送测试消息时,我才会得到以下响应:
{:body=>"{\"multicast_id\":7171621681139926581,\"success\":1,\"failure\":0,\"canonical_ids\":0,\"results\":[{\"message_id\":\"0:1556626239337337%e087ffcde087ffcd\"}]}", :headers=>{"content-type"=>["application/json; charset=UTF-8"], "date"=>["Tue, 30 Apr 2019 12:10:39 GMT"], "expires"=>["Tue, 30 Apr 2019 12:10:39 GMT"], "cache-control"=>["private, max-age=0"], "x-content-type-options"=>["nosniff"], "x-frame-options"=>["SAMEORIGIN"], "x-xss-protection"=>["1; mode=block"], "server"=>["GSE"], "alt-svc"=>["quic=\":443\"; ma=2592000; v=\"46,44,43,39\""], "accept-ranges"=>["none"], "vary"=>["Accept-Encoding"], "connection"=>["close"]}, :status_code=>200, :response=>"success", :canonical_ids=>[], :not_registered_ids=>[]}
Run Code Online (Sandbox Code Playgroud)
但是在电话上我没有收到通知。
我的 ruby 后端如下所示:
fcm_client = FCM.new(server_key)
# options = {:notification => "Test notification",:data => {:message => "This is a FCM Topic Message!"}}
options = { "notification": {
"title": "Portugal vs. Denmark",
"body": "5 to 1"
}
}
user_device_ids.each_slice(20) do …Run Code Online (Sandbox Code Playgroud)