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 Aardvarklord · Dec 07, 2019 at 10:39 AM · androidpush notification

Firebase Cloud Messaging notifications

I'm trying to achieve the following behavior for push notifications using Firebase Cloud Messaging for Unity in an Android app.

  1. If app is in foreground, handle directly in app (access key-value pairs in push message). Do not show notification in system tray. (Or possibly show notification in tray but then I must be able to clear it from the app)

  2. If app is in background, show notification in system tray. When user clicks notification or clicks app icon on desktop, bring app to foreground, clear system tray and access key-value pairs in push message.

  3. If app is not running, show notification in system tray. When user clicks notification or starts app from icon, start app, clear system tray and access key-value pairs in push message.

    Depending on whether I populate "data" and/or "notification" fields in the push message in the server I can achieve 1,2,3 above in different combinations but I cannot figure out how to achieve all of them.

Comment
Add comment · Show 3
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 AskCarol ♦♦ · Dec 11, 2019 at 04:01 PM 0
Share

$$anonymous$$aybe have android activity updated and $$anonymous$$essageForwardingService service added to android manifest as described here https://firebase.google.com/docs/cloud-messaging/unity/client#note_for_android

avatar image Aardvarklord AskCarol ♦♦ · Dec 15, 2019 at 08:25 PM 0
Share

Thanks, I will look into this!

avatar image Aardvarklord AskCarol ♦♦ · Dec 21, 2019 at 11:05 AM 0
Share

Sorry, I don't understand. According to my Assets/Plugins/Android$$anonymous$$anifest.xml I am using $$anonymous$$essagingUnityPlayerActivity as my $$anonymous$$AIN LAUNCHER Activity. Also, the manifest contains a $$anonymous$$essageForwardingService.

$$anonymous$$y problem is that if the App is in background or not running, and the user brings the app to foreground by clicking the app icon (not the notification in system tray), the FC$$anonymous$$ notification is not delivered to the App.

Would creating a custom Activity implementing onNewIntent as detailed on the page you linked to really solve this? I would have guesed i would have to somehow check for notifications in OnAwake but I cannot figure out how. (possibly by calling native android classes via AndroidJavaObject but it feels like a hack...)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by AskCarol · Dec 11, 2019 at 03:59 PM

Have you taken a look at the Quick Start sample project for Unity:

https://github.com/firebase/quickstart-unity

Comment
Add comment · Show 2 · Share
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 Aardvarklord · Dec 15, 2019 at 08:22 PM 0
Share

Thanks for the tip, I did have a look and I think I'm doing it right. I discovered that when running a development build for Android it seems the app can be active even though the mobilde device has activated the lock screen behind the app and in this state it seems Firebase considers the app to be in the background even though it's active.

After this insight the only thing I'm missing is some way to check if there are any notifications in the system tray when the app is brought to foreground since I would like to process any notifications also if the app is launched from the app icon (if launched from the notification in the system tray I receive the notification).

avatar image UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396 Aardvarklord · Jan 10, 2021 at 01:26 AM 0
Share

Hi, did you manage to solve this? When in app is it possible to not display messages in the notification tray? Also, can I choose to not show in the notification tray even if a message was received (probably certain times of the day).

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

256 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 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 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

Parse push notification doesn't show 0 Answers

FCM white icon 1 Answer

Game crashes on push notification (Android) 1 Answer

Game Thrive (One Signal) causes game to crash when calling init method. 1 Answer

Error when checking if a notification has been delivered 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