- Home /
FCM Unity plugin Data messages in background
Is there any way in which I can get the data message (not notification messages) when app is in background. I don't mind writing native Java code and adding an aar file, but I need to get the data messages from Firebase in my Android app even when my app is in background.
For now I know firebase unity plugin actually caches the data messages when in background and gives the callback when app is launched, but it does not serve the purpose of a push notification, i.e. to bringing a user back to the app. I know this must be possible, but not how.
Or is there a way of doing this without Firebase Unity plugin, i.e. by using native firebase-messaging aar library?
Answer by Bunny83 · Jun 25, 2019 at 10:23 AM
Unity is a foreground activity like almost all apps. Android can only have one foreground app at a time. When you switch to another app your app is essentially out of business. At this time the OS can actually decide to completely kill your app if memory is needed.
What you need is creating a native background service this might be a good start. I haven't used firebase so i can't help you any further here. However you should start reading the documentation and the API reference
Your answer
Follow this Question
Related Questions
Unity Android Push notification 1 Answer
Android local notifications 0 Answers
Google Cloud Messaging for Android 1 Answer