消息已发送但未收到

Message was sending but not received

我正在使用 fcm gem。

这是我的代码:

module NotificationHelper
  require 'fcm'

  def send_notification(location, message,user_id )
    firebase_key = Rails.application.secrets.firebase_key

    user = User.find_by(id: user_id)
    fcm = FCM.new(firebase_key)
    registration_ids= [user.device_token] # an array of one or more client registration tokens
    options = {:data => {"message": message, "location": location}}
    response = fcm.send(registration_ids, options)
  end
end

这是我的回复:

{"status_code": 200, "response": "success", "canonical_ids": [], "not_registered_ids": []}

更改以下选项:

options = {
        priority: 'high',
        data: {
            message: message,
            location: location
        },
        notification: {
            body: message,
            location: location,
            sound: 'default'
        }
    }

这对我有用。