Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by victoranyirah · Jan 28, 2018 at 11:07 AM · networkingnotifications

Firebase message notification has empty data in body

My server is setup to send notifications to my unity app with custom data in the body, but when received on the unity end, the body field is empty..even the notification data parts. The actual notification itself works fine and is shown on the device, just the data is missing.

I saw someone else had this exact issue here but there was no resolution

https://stackoverflow.com/questions/46219821/firebase-messaging-in-unity-getting-empty-message

Even messages I send from the firebase console with data don't have the data when it hits the client so I don't think my server-side sending logic is the problem. The returned response from sending to the firebase endpoint is always a "success" with no failures too.

Here is my server-side function to send data with no notification. When I call this the Message.From field is set.

 def send_message(device_token, data):
 url = "https://fcm.googleapis.com/fcm/send"
 header = {'Content-Type' : 'application/json',
     'Authorization' : 'key=' + os.environ.get('FIREBASE_API_KEY')}
  data = {
 "data" :  data,
 "to" : device_token
 }
 resp = requests.post(url, headers=header, json=data)
 print data
 print resp.text
 return resp.text

This is the method I use to send notification with body data.

 def send_notification(to, title, body, data):
 url = "https://fcm.googleapis.com/fcm/send"
 header = {'Content-Type' : 'application/json',
     'Authorization' : 'key=' + os.environ.get('FIREBASE_API_KEY')}
 notification = {
         "to" : to, 
         "notification" : {
             "title": title,
             "body": body
              }
         }
 if data != None:
  notification["data"] = data
 resp = requests.post(url, headers=header, json=notification)
 print resp.text
 return resp.text

On Unity client side..heres is my code for OnMessageReceived

 private void OnMessageRecieved(object sender, MessageReceivedEventArgs e) { 
 Debug.Log("Received a new message from: " + e.Message.From);
 Debug.Log("Receieved from : " + e.Message.From);
 Debug.Log("Raw data is : " + e.Message.RawData);

 Debug.Log("TO : " + e.Message.To);
 Debug.Log("Message_ID:" + e.Message.MessageId);
 Debug.Log ("PRIOIRITY" + e.Message.Priority);

 string text = GetFirebaseMessageString (e.Message);
 Debug.Log("Raw msg is : " + text);
 }

Here is the code for setting the Firebase.Messaging message received callback.

     FirebaseMessaging.MessageReceived += OnMessageRecieved;

This currently happens on iOS. Haven't tested android. Currently completely out of ideas on why it is happening. Thought it had something to do with APNS certificates, so I switched to the Auth Key. Made no difference.

Any ideas? Anyone run into this issue? Spent all day on it and have no luck. Really frustrated.

Please help...to avoid this issue I'll have to poll my server like every 20 seconds or so..my bill will go up a ridiculous amount :(

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pako · Jan 28, 2018 at 11:15 AM 0
Share

I suspect that this might be a problem with the Firebase Unity SD$$anonymous$$s (not Unity itself). I mean, the SD$$anonymous$$ is responsible for delivering the content of the message, and if it's not delivering the message, it should be the SD$$anonymous$$'s problem... Emphasis here on "I suspect".

$$anonymous$$aybe you should ask a relative question to Firebase support.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

108 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

Google Cloud Messaging for Android 1 Answer

Unet: Discern between user disconnection and connection lost 1 Answer

Create notification if already there is no notification created 0 Answers

List of players on the server only with SyncStructList? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges