Mobile Local Notifications for Unity 5.x.x gives you the ability to create local notifications with Emoji for your games and apps.
The plugin supports iOS 9.0 and later, Android 4.0.3 and later and is compatible with Unity 5.x.x. Support Android 8+ (channels)
You can play the demo scene (Assets/MobileLocalNotifications/Scenes/Demo.unity) to check notifications on your device.
Test guide
- Create a new empty project.
- Import the package (Assets/Import Package/Custom Package).
- Open and add in Build Settings demo scene Assets/MobileLocalNotifications/Scenes/Demo.unity.
-
- (iOS) Build X-Code project, Run project in X-Code.
- (Android) Build project to android device.
- Press Button “Send Notification(wait 10 seconds)”.
Using the plugin
Access to functions on the Android and iOS is identical.
LocalNotificationsManager.SendNotification(int id, long delaySeconds, string title, string message, string ticker,
string iconSmall = “”, string iconBig = “”, bool sound = true, bool vibrate = true, bool lights = true,
Color32 color = default(Color32), string fileName = “”)
id - id of notification.
delaySeconds - Delay before view notification.
title, message, ticker - texts for view.
iconSmall, iconBig - name file with icon. If empty - is used app_icon.
sound, vibrate, lights, color - special features, are available depending on the device, operating system, settings.
fileName - if not “”, for click to notification, open fileName in Gallery (only Android)
LocalNotificationsManager.InitNotifications()
Only iOS, for user open permission dialog for notifications. Automatically call for LocalNotificationsManager.SendNotification().
LocalNotificationsManager.ClearLocalNotificationsInPanel()
Clear notifications that are already shown.
LocalNotificationsManager.CancelLocalNotification(int id)
Cancellation of a scheduled notification.
LocalNotificationsManager.RefreshGallery(string fileName)
Only Android. Refresh Android Gallery for fileName
LocalNotificationsManager.GetLastClickedNotificationId()
Only Android. Return int value. If -1, app open without click to notification, else return id of clicked notification. When reused, it always returns -1.
Features
- The same code for iOS and android
- Support Emoji for notifications
- Support show notifications after a device reboot for Android
- Demo scene
- Compatible with Unity 5, 2017, 2018, 2019(with fix, see FAQ)
- 40 embeded Emoji
- Add any of your Emoji
Add new Emoji
- Find code of Emoji: Full Emoji List, v15.1
Example, code U+1F600 (short name: grinning face), for c# it’s U0001F600 (32bit Emoji)
Example, code U+263A (short name: smiling face), for c# it’s u263A (16bit Emoji) - Open file: Assets/MobileLocalNotifications/Scripts/EmojiList.cs
- Add new line, example
public static string GrinningFace = “\U0001F600”;
public static string SmilingFace = “\u263A”; - Save file
Add new icon for Android
- Create directoty Assets/Plugins/Android/res/drawable-xxxhdpi (or any other size)
- Copy into directory file with icon (png)
- Use in parameters iconSmall, iconBig (without extension)
Embeded icons:
mln_notification - for sample
mln_blank_notification - full transparent icon
FAQ
- For use Gradle and Minify, need add line into Assets\Plugins\Android\proguard-user.txt
-keep class ru.LittleStories.LocalNotifications.** { *; } - For Unity with new gradle Unity2018.3 and later need ignore import file Assets/Plugins/Android/mainTemplate.gradle