- Home /
LocalNotifications deprecated in Unity 5
I want to create a new LocalNotification, so, when i try to create a new object:
LocalNotification ln = new LocalNotification();
My ln object has no attributes nor methods, and Mono shows me a tip saying that LocalNotification is deprecated and I should use iOS.LocalNotification instead. When i try to use
iOS.LocalNotification ln = new iOS.LocalNotification()
Mono highlights LocalNotification with red, showing that iOS, does't contain a definition for it, in fact, it has no definitions at all. Anyone has any idea on how to get LocalNotifications working on Unity3D 5?
Answer by jmorhart · Aug 05, 2015 at 12:19 AM
I found this error too. It seems as though Unity hasn't exactly deprecated UnityEngine.LocalNotification, it's more like it's been moved into a new namespace: UnityEngine.iOS.LocalNotification. You can get around it by adding this line to the top of your code:
using LocalNotification = UnityEngine.iOS.LocalNotification;
Basically, this is telling the compiler that whenever a variable of type LocalNotification is declared, don't look at UnityEngine.LocalNotification, instead look at UnityEngine.iOS.LocalNotification.
Answer by DoTA_KAMIKADzE · Jun 13, 2015 at 10:03 PM
I'm not an iOS dev, but LocalNotification can be seen perfectly fine in my Unity v5.1.0f3 using full unambiguous path:
UnityEngine.iOS.LocalNotification ln = new UnityEngine.iOS.LocalNotification();
$$anonymous$$y version is 5.0, and i tried this path too, still no methods.
I'm definitely not going to degrade just to try if the version is a core of a problem. Have you checked if Unity itself gives any errors in console log? $$anonymous$$g. add for example this somewhere in your code:
UnityEngine.iOS.LocalNotification ln = new UnityEngine.iOS.LocalNotification();
ln.alertAction = "Something";
then save and switch to Unity Editor and check console, if everything is fine then surely something is wrong with your $$anonymous$$onoDev installation.
Your answer
Follow this Question
Related Questions
How to know when my game is in background? 1 Answer
iOS Turn Off Push Notifications Pop Up 0 Answers
Simultaneous Android and iOS development 1 Answer
Ran out of trampolines of type 2 - iOS 2 Answers
Device Auto-Rotation 1 Answer