Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 oliver-jones · Jul 04, 2013 at 02:42 PM · iphonenotificationservices

iPhone - NotificationServices Not Working?

Hello,

I'm pretty new to developing on the iPhone, and I'm trying to get the alert message to popup using the 'NotificationServices'. But it just doesn't seem to be doing anything?

 function Start(){
 
     var notif = new LocalNotification();
     notif.alertBody = "Hello!";
     NotificationServices.PresentLocalNotificationNow(notif);
 }
 
 
 function Update(){
 
     if (NotificationServices.localNotificationCount > 0) {
         Debug.Log(NotificationServices.localNotifications[0].alertBody);
         NotificationServices.ClearLocalNotifications();
     }
 }

Nothing pops up at all, nothing! Although, within the xcode debugger, I do see the 'Hello!' message:

 Loading /var/mobile/Applications/109EED84-4427-4361-A38A-0FE9FE7A9712/sandboxiSO.app/Data/Managed/Assembly-UnityScript.dll into Unity Child Domain
 - Completed reload, in  0.050 seconds
 -> applicationDidBecomeActive()
 -> force accelerometer registration
 Hello!
 UnityEngine.Debug:Internal_Log(Int32, String, Object)
 UnityEngine.Debug:Log(Object)
 SceneController:Update()
  
 (Filename: /Applications/buildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/iPhonePlayer-armv7/UnityEngineDebug.cpp Line: 43)

Any reason why this isn't working? Thanks

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Umai · Dec 08, 2014 at 02:10 AM

I think you're doing it wrong.

The main flow is:

  1. Create a LocalNotification instance.

  2. Set the parameters of that instance, most notably the fireDate must be set at the point in future time when you wish the notification to be fired. I guess you can set it to "now" or past time of course, and the local notification would be fired "immediately".

  3. Schedule the instance. This is something you haven't done in your code. Looks like you should change NotificationServices.PresentLocalNotificationNow(notif) to NotificationServices.ScheduleLocalNotification(notif) really.

  4. I'm not sure here but your update looks fine, however you will probably need to make sure that you add this script to a persistent GameObject on some scene. I'm fairly new to Unity itself; I have 4-5 years experience from iOS local notifications however.

Some code example for scheduling:

     LocalNotification notification = new LocalNotification();
     notification.fireDate = datetimeWhenyouwantittofire; // System.Datetime
     notification.alertBody = "This is my message to you!";
     NotificationServices.ScheduleLocalNotification(notification);
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
0

Answer by nihits · Mar 29, 2017 at 05:00 PM

call RegisterForNotifications

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

17 People are following this question.

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

Related Questions

Low frame rate with only one texture on iPad 4 Answers

How can I list used assets on Unity Pro - iPhone Pro 1 Answer

iphone walk-through file size question? 0 Answers

Does Unity 3 have native resource localization support? 4 Answers

Communication iPhone Webplayer 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