Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Firebase Topic Notifications Message Title
Started by kakula Jul 22 2019 03:58 PM

No replies to this topic
firebase topic notifications message title
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

kakula

[GLOBAL: userInfoPane.html]
kakula
  • Enthusiast

  • 91 posts
  • Corona SDK

Hi,

 

i'm having some trouble with setting the title and body for Firebase notifications

 

the phone is receiving notifications but it only shows app name ... it does not show a title or body for the notifications

 

here's the code:

local function onSendNotification(event)
  local errorMessage = nil
  if event.isError then
    errorMessage = "Failed to connect to the server."
  elseif event.status == 200 then
  elseif event.status == 400 then
    errorMessage = event.response
  elseif event.status == 401 then
    errorMessage = "Failed to authenticate the sender's Google Play account."
  elseif (event.status >= 500) and (event.status <= 599) then
    errorMessage = "Server failed to process the request. Please try again later."
  end
end
local function sendNotificationTopic()
  if not serverKey then
    return
  end--"message": "Blood Donation Required"
  local jsonMessage =[[{"to": "/topics/donateblood","data": {"message": "Blood Donation Required"}}]]
  local url = "https://gcm-http.googleapis.com/gcm/send"
  local parameters =
  {
    headers =
    {
      ["Authorization"] = "key=" .. serverKey,
      ["Content-Type"] = "application/json",
    },

    body = jsonMessage,
  }
  network.request(url, "POST", onSendNotification, parameters)
end

sendNotificationTopic()



[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: firebase, topic, notifications, message, title