[RELEASED] Mobile Local Notification with support Emoji

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.

[AssetStore]

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.
    1. (iOS) Build X-Code project, Run project in X-Code.
  1. (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

When specifying a filename for the iconSmall and iconBig parameters, where are those files supposed to be placed? What format should the icon image picture be in?

Can you provide an example

Hi
I will try to make an instruction as soon as possible. Lay it in this thread and update the asset.

Update asset.

Add new icon for Android

Create directory 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

Does this still show notifications after a device reboot?

On Android?

Added show notifications after a device reboot for Android

Added link notifications on Android for images with refresh Gallery

thanks so much for link in notifications !!!

Thanks for the nice comment!

Hey I ran into a problem. I just imported it into my project and tried to build only the demo scene for Android. After I tap a button to send notification error appears. I tried another plugin for local notification before (GitHub - Agasper/unity-android-notifications: Unity3D Plugin for Android local notifications with example project), but I had the same problem. Dont you know what could I do to fix it? I should release the game next week and I cant without notifications.
Btw, the implementation is very easy and awesome, but I cant get it work.

EDIT: I now figured in new demo project, that plugin works ok with Internal (default) build system, but not with Gradle (new). Problem is, I need gradle cause I have too much reference fields or what when I use Internal (some dex-compile error or what)

Hi. You can send your gradle file?

Sure, here it is. Its just basic mainTempleate.gradle without changes (i suppose that line compile fileTRee(dir: ‘libs’, include: [‘*.jar’]) in dependencies should include even MobileNotification.jar plugin.
And if it doesnt, I just wonder what to add and where (sorry, i didnt find anything about that in Unity Docs).

Btw, of course I have it as .gradle, but it would not let me upload it here due to uknown file type.

EDIT
I already tried
compile(name:‘./MobileLocalNotifications’, ext:‘jar’)
and
compile files(‘MobileLocalNotifications.jar’)
in the dependencies element
both approches definitely find the file (it would crash with some “no file error”, i tested it)
The first approach failed with attached error, second one succeeded without build error, but in game is still error “NoSuchMethod”

Thanks

3421853–270024–mainTemplate.txt (1.14 KB)

You use Gradle and Minify. It is necessary to add to the Assets\Plugins\Androids\proguard-user.txt line
-keep class ru.LittleStories.LocalNotifications.** { *; }

1 Like

Awesome, mate, your plugin is the best (maily support :)). I’ll definitely provide some feedback on assetstore.
One more thing. When I SendNotification and close the game (not minimize, but close), notification won’t appear. Do you know where the problem could be?

Thanks mate :slight_smile:

Hmm. On my device all ok. What device and android version?

Android 6.0

EDIT:
It seems my phone is only dumb :slight_smile: It works fine on other devices.

Unofrtunately I ran into another issue. I added icons in mutiple sizes. Put it in folder Plugins/Android/res (as shown in the image) but if I provide “ic_launcher” or “ic_stat_micro_icn_03_2_01”, game always crashes. Another wierd think is: when I use mln_notification, it uses main game icon (but it didn’t crash). Maybe it ignores res folder? I read somewhere that Unity won’t support res folder or something like that.

Please, send res folder. I check on my devices. May be problem in images

I have few questions.

  1. Does it sends notifications after selecting a fixed time even after reboot ( iOS )
  2. Cna we change notification icon for iOS too?

Hi. For IOS, I use UnityEngine.LocalNotification with my extension on c#. I no find change icon in UnityEngine.LocalNotification. If you know how to do it (example or article), write me, I update asset.
Now, I find info for rich local notification on iOS and Android.