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
0
Question by mazhar-ali · Jan 11, 2016 at 01:18 PM · unity 4.6notifications

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.

Comment
Add comment · Show 5
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 gjf · Jan 08, 2016 at 06:02 PM 0
Share

please format ALL of your code.

avatar image mazhar-ali · Jan 08, 2016 at 06:21 PM 0
Share

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.

avatar image EvilTak mazhar-ali · Jan 11, 2016 at 10:45 AM 0
Share

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.

avatar image mazhar-ali EvilTak · Jan 11, 2016 at 10:49 AM 0
Share

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.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How backward-compatibly write NotificationServices in Unity 2 Answers

CSharpNotificationCenter Posting Messages with data 4 Answers

Trigger notification permission popup on iOS again 1 Answer

Mobile Notifications Icons on Android. 1 Answer

Unity 4.6 text rendering 0 Answers


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