2

Using fcm for push notification ios and Android

Request:

fcm = FCM.new(ENV["FCM_TOKEN"])
options = {data: {message: message}, priority:'high'}
response = fcm.send(device_tokens, options)

Response:

{:body=>
"{"multicast_id":8122297942819980145,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1505802064679190%9310a6bdf9fd7ecd"}]}",
:headers=>
{"content-type"=>["application/json; charset=UTF-8"],
"date"=>["Tue, 19 Sep 2017 06:21:04 GMT"],
"expires"=>["Tue, 19 Sep 2017 06:21:04 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="39,38,37,35""],
"accept-ranges"=>["none"],
"vary"=>["Accept-Encoding"],
"connection"=>["close"]},
:status_code=>200,
:response=>"success",
:canonical_ids=>[],
:not_registered_ids=>[]}

Found few discussion but didn't help

issues/15

issues/1

passing the options: 'priority': 'high' might solve the issue. But doesn't work for me.

Facing an issue with Ios Notification which is not receiving at device. Same setup is working fine with Android.

Please let me know if i'm doing anything wrong here.

praaveen V R
  • 1,259
  • 1
  • 11
  • 20
  • You need configure separate payload for iOS which will be different from Android. – Nauman Malik Sep 21 '17 at 07:55
  • @NaumanMalik can you tel me sample payload? – praaveen V R Sep 23 '17 at 09:36
  • tried with different payload as well didnt work options = {data: {message: message, notify_type: notify_type}, priority:'high', notification: { body:'BODY', title:'TITLE' }, mutable_content: true } same response and didn't receive in device – praaveen V R Sep 26 '17 at 12:45

1 Answers1

1

Initially I faced the same issue, but then after looking for solutions, I found this comment https://github.com/spacialdb/fcm/issues/1#issuecomment-223152688.

The payload should have a notification object with title and body attrs,

options = { notification: {title: "Some Title", body: "Some description"}, data: {extra_data: {}}, priority: 'high' } Modifying the options payload like above worked form me.

I have also answered for your issue here