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
1
Question by Sruba · Apr 05, 2017 at 12:19 PM · androidiosmobilenotifications

Local notification with closed app

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?

Comment
Add comment · Show 1
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 baopham · Nov 07, 2017 at 08:27 AM 0
Share

Can you please let me know which asset you used to create local notifications for iOS while app is running in background? I’m looking for one that can do that. Thanks

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by liortal · Apr 05, 2017 at 03:48 PM

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.

Comment
Add comment · Show 4 · 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 Sruba · Apr 06, 2017 at 07:25 AM 0
Share

Thanks for your answer. I managed to achieve what i intended to on iOS using Unitys NotificationServices. I still need to do something about android. I have some experience with android native code so I think I'll manage to do it but it would be great if I could get some pointers :) If I remember correctly, on android i used BroadcastReceiver for notifications. I also read something about setting alarms for notifications. Is any of those a correct way?

avatar image liortal Sruba · Apr 06, 2017 at 03:50 PM 0
Share

You use the system's Alarm$$anonymous$$anager to time a specific thing to occur. you give it a PendingIntent object, that specifies what should happen (wrap an Intent to call your broadcast receiver in it).

In your broadcast receiver, which catches the broadcast notification as it occurs, you build a notification object and present it to the user. Easy as pie :)

avatar image liortal liortal · Apr 06, 2017 at 03:51 PM 0
Share

I hate to push my services too strong, but just in case you need my professional assistance, feel free to contact me here: https://www.fiverr.com/lysergide

avatar image Yuriy-Ivanov Sruba · Apr 06, 2017 at 06:12 PM 1
Share

Yes, it's correct. See also https://developer.android.com/training/scheduling/alarms.html & https://developer.android.com/training/notify-user/build-notification.html

avatar image
1

Answer by AquinoJ · Apr 10, 2019 at 08:34 PM

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!

https://assetstore.unity.com/packages/tools/integration/native-android-toolkit-mt-139365

Comment
Add comment · 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
-1

Answer by Yuriy-Ivanov · Apr 07, 2017 at 02:42 PM

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.

Comment
Add comment · 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

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Android/iOS notifications when the game is not running 1 Answer

Which mobile devices do not support stencil buffers? 1 Answer

Raycast from player to touch point? 2 Answers

Grid Movement Controls on Mobile - UX Problem 0 Answers

System.Diagnostics.Process on iOs and Android 1 Answer


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