4

I am building a simple game where 2 people can duel against each other. I am using GameSparks as a back end. My problem is, that whenever player #1 casts a spell that is channeling, player #2 can see the channeling only when his screen is turned on and in focus.

Whenever player's #2 screen turns off, the app is not active anymore so the spell is not being casted at him. When player #2 turns on the screen, the channeling starts, but player #1 was already done channeling a while ago.

I assume that is related to the way Android system works. It puts apps that are not in focus on pause.

My problem now is, how can I make sure that player #2 gets a notification whenever he is hit by the spell without a need to use any third party service to keep the app alive (to avoid huge battery consumption) and also without a need to use push notifications (as from what I've heard, if there is a high load, the push doesn't happen right away, since there is a queue)

Ondrej Tokar
  • 4,898
  • 8
  • 53
  • 103
  • How about using GCM for notifications ? – Panda Jun 07 '16 at 20:00
  • That's what I said, it's a push notification which can be delayed if there is a high load. In game such as this it's unacceptable. Unless you know otherwise about the GCM delays. Though thanks for suggestion. – Ondrej Tokar Jun 07 '16 at 20:02
  • @JoeBlow the session is running on the server and there is no problem of getting the status of the game any time app gains focus back again. What is important for me is that user is notified about incoming spell even though screen is turned off, which seems to be impossible so far. – Ondrej Tokar Jun 07 '16 at 21:17
  • Hi @JoeBlow, unfortunately my question hasn't been fully answered. I gave you +1, but I might still get an answer from someone else perhaps. – Ondrej Tokar Jun 18 '16 at 12:43
  • @JoeBlow your comments were terribly rude so I don't consider your answer good. – Ondrej Tokar Jun 20 '16 at 12:17

1 Answers1

0

Application.runInBackground is only for Webplayer (and PC, not sure about the last one though).

Unity runs as Activity in Android, hence it gets paused when it's loses it's focus. That's by (Android) Design and works as intended.

Topic link

ARTAGE
  • 379
  • 2
  • 4
  • 14