I'm trying to send push notification messages using the FCM gem to a android phone. I'm able to get the device token and I think I set everything up the way it should. Only when I use my ruby back-end to send a test message I get the following response:
{: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=>[]}
but on the Phone I don't get a notification.
my ruby backend looks like this:
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 |device_ids|
response = fcm_client.send_notification(device_ids, options)
p response
end
when the app is open it shuts down and I find this error:
java.lang.RuntimeException: Unable to instantiate service NAME_OF_THE_APP.java.MyFirebaseMessagingService: java.lang.ClassNotFoundException: Didn't find class "NAME_OF_THE_APP.java.MyFirebaseMessagingService"
Now I'm not a Java Expert So I don't know what is wrong at this point. I'm testing it on a Huawei Phone.