- Home /
How to send notification when the games is not running?
i want to send local notification when the game is not running. Something like when the energy is full users should get notification, "Energy full". I have tried following code, everything in it is working properly except notification.
private void OnTick(object source, ElapsedEventArgs e) {
energyTick += 1;
Debug.Log (energyTick);
if (energyTick > maxEnergy) {
Debug.Log("Energy Tick is Max");
energyTick = maxEnergy;
int NotificationId = AndroidNotificationManager.instance.ScheduleLocalNotification("Energy Full", "Come Back and play", 3);
aTimer.Stop ();
}
}
But when I execute the same notification code in button (int the following code) it works.
if (GUI.Button(new Rect(5, 5, 300, 100), "Send Notification")) {
int NotificationId = AndroidNotificationManager.instance.ScheduleLocalNotification("Hello", "This is local notification", 2);
}
Where I am wrong please let me how can send notification even if the game is not running. Thanks in advance.
sorry i tried but its not formatting better than this, its my first question on this forum. If want to anything to explain i will explain it.
Just put an extra new line before each line of code. Have you tried searching on the internet for this problem? I'm positive that others will have had this problem before.
Actually I have made an energy system that increases in background with time, I want if the energy reaches to its maximum value, Local notification should be send to user if the game is not running.