I’ve been trying to make a notification appear when user doesn’t launch the game for 24 hours. I tried using few plugins from asset store but none of them worked after closing down the app, ony when it was running in the background. I was thinking about using Firebase but i’m not shute if it’s a good option, if possible i would like to have notification even offline.
I was wondering how is it done in other Unity games?
I needed to do this a short time ago, to notify my players, that the spell was ready in my game. I discovered that I needed to schedule the notification in the future, when the notification was ready. Since I’m not a good programmer, I’ve researched something in the asset store and found a tool that accesses native Android features so I can easily schedule my notifications! I only paid $ 9.90, and it also has several other spectacular functions!
A local notification does not require any server integration (e.g: Firebase).
The way it works, is you schedule a notification to show up after some time (for example - after 24 hours).
When you launch the game, you can cancel the notification, and when you leave the game, you reschedule it.
The operating system (Android and iOS) both take care of registering the information about the notification, so it’s not necessary to keep the game / app running in order for it to work.
There’s another, more complex case where the device is rebooted in between. I believe there may be solutions for that, but i am not 100% sure.
For implementation, if you’re not familiar with the native code required for this (on each platform), your best bet would be to use a plugin that provides this functionality.
Local notifications work well if the app is closed. But, it should not be force-stopped (on Android), as any activity of the app is stopped by OS in that case - it’s done on purpose by Google. Some Android devices (many ASUS models, f.e., but not only) unfortunately force-stop any applications with no Activities, except of some built-in white-list, to save power. In that case you can’t do anything, even push notifications won’t help (as they are blocked for force-stopped apps too). Also, on Android scheduled local notifications are not by default persistent after a device reboot, but there are ways to implement it. There are some Unity assets (such as our UTNotifications) which can do it. But of course you also can implement it on your own using native plugins.