Search Unity

[RELEASED] Mobile Local Notification with support Emoji

Discussion in 'Assets and Asset Store' started by Lucasito, Oct 5, 2017.

  1. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    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
    1. Create a new empty project.
    2. Import the package (Assets/Import Package/Custom Package).
    3. Open and add in Build Settings demo scene Assets/MobileLocalNotifications/Scenes/Demo.unity.
    4. 1. (iOS) Build X-Code project, Run project in X-Code.
      2. (Android) Build project to android device.
    5. 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
    1. The same code for iOS and android
    2. Support Emoji for notifications
    3. Support show notifications after a device reboot for Android
    4. Demo scene
    5. Compatible with Unity 5, 2017, 2018, 2019(with fix, see FAQ)
    6. 40 embeded Emoji
    7. Add any of your Emoji

    Add new Emoji
    1. Find code of Emoji: https://unicode.org/emoji/charts/full-emoji-list.html
      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)
    2. Open file: Assets/MobileLocalNotifications/Scripts/EmojiList.cs
    3. Add new line, example
      public static string GrinningFace = "\U0001F600";
      public static string SmilingFace = "\u263A";
    4. Save file

    Add new icon for Android

    1. Create directoty Assets/Plugins/Android/res/drawable-xxxhdpi (or any other size)
    2. Copy into directory file with icon (png)
    3. Use in parameters iconSmall, iconBig (without extension)
    Embeded icons:
    mln_notification - for sample
    mln_blank_notification - full transparent icon


    FAQ
    1. For use Gradle and Minify, need add line into Assets\Plugins\Android\proguard-user.txt
      -keep class ru.LittleStories.LocalNotifications.** { *; }
    2. For Unity with new gradle Unity2018.3 and later need ignore import file Assets/Plugins/Android/mainTemplate.gradle


    Screenshot1.png Screenshot2.png
     
    Last edited: Oct 17, 2019
  2. ChricKCK

    ChricKCK

    Joined:
    May 9, 2014
    Posts:
    8
    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
     
  3. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Hi
    I will try to make an instruction as soon as possible. Lay it in this thread and update the asset.
     
  4. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    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
     
    Last edited: Dec 20, 2017
  5. Cypras

    Cypras

    Joined:
    Oct 25, 2013
    Posts:
    52
    Does this still show notifications after a device reboot?
     
  6. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    On Android?
     
  7. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Added show notifications after a device reboot for Android
     
  8. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Added link notifications on Android for images with refresh Gallery
     
  9. mimicryArt

    mimicryArt

    Joined:
    Oct 23, 2015
    Posts:
    3
    thanks so much for link in notifications !!!
     
  10. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Thanks for the nice comment!
     
  11. vratislavino

    vratislavino

    Joined:
    Mar 7, 2013
    Posts:
    12
    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 (https://github.com/Agasper/unity-android-notifications), 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)



     
    Last edited: Mar 11, 2018
  12. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Hi. You can send your gradle file?
     
  13. vratislavino

    vratislavino

    Joined:
    Mar 7, 2013
    Posts:
    12
    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
     

    Attached Files:

    Last edited: Mar 12, 2018
  14. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    You use Gradle and Minify. It is necessary to add to the Assets\Plugins\Androids\proguard-user.txt line
    -keep class ru.LittleStories.LocalNotifications.** { *; }
     
    vratislavino likes this.
  15. vratislavino

    vratislavino

    Joined:
    Mar 7, 2013
    Posts:
    12
    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 :)
     
  16. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Hmm. On my device all ok. What device and android version?
     
  17. vratislavino

    vratislavino

    Joined:
    Mar 7, 2013
    Posts:
    12
    Android 6.0

    EDIT:
    It seems my phone is only dumb :) 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.
     
    Last edited: Mar 15, 2018
  18. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Please, send res folder. I check on my devices. May be problem in images
     
  19. cl0n

    cl0n

    Joined:
    Sep 9, 2015
    Posts:
    10
    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?
     
  20. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    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.
     
  21. vratislavino

    vratislavino

    Joined:
    Mar 7, 2013
    Posts:
    12
    Hello, it's me again :)
    I'd like to ask one more question. Plugin works well on most devices, but it's not working on Android 8. I've read some threads about Android 8 using different API calls for native share and notifications. Maybe it's a possibility. I've created notification 10 secs after application starts, but it's exactly as I said - not working on Android 8

    Thanks in advance :)
     
  22. TerraCo

    TerraCo

    Joined:
    Jun 8, 2013
    Posts:
    26
    Hey,

    I'm having the same problem as vratislavino. Local notifications were working fine on my device, but it updated to Android 8.0 last night and they are no longer working. I think I read it's to do with Android 8 requiring a notification channel, but don't know enough about Android code to check for myself.

    EDIT: I tried this open source plugin that does indeed work on Android 8.0, but it doesn't include Emojis which my project requires. Maybe Lucasito can use it for reference to identify the cause?

    Cheers,
    TerraCo
     
    Last edited: Jul 10, 2018
  23. C-Game

    C-Game

    Joined:
    Jul 8, 2017
    Posts:
    1
    Hey, I used the open source plugin for Android 8 and this also support emojis. Just add "\u263A" to your string to a smile emojis. Other Emojis-Codes you need to search on google. My Problem is that the open source plugin don't work with the facebook-sdk. when i recieve a notification the app crush.
     
    Last edited: Jul 10, 2018
  24. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Hi!
    Thanks for info. I will try in the near future to update the asset for correct work on Android 8
     
  25. vratislavino

    vratislavino

    Joined:
    Mar 7, 2013
    Posts:
    12
    Hello I'd like to ask, if you tried to fix plugin for Android 8. We have to release a game in next few day and it would be nice to have that working for all devices :) Thanks in advance
     
  26. zeusrami

    zeusrami

    Joined:
    Dec 12, 2012
    Posts:
    17
    Hi, I recently bought you the assets. Is there a way to make the notification with certain sound ? I need a particular sound for my application.
    And also Is there a way to create a daily notification? twice a day for example?
     
  27. wasedaigo

    wasedaigo

    Joined:
    Apr 14, 2013
    Posts:
    7
    I'll buy the asset once Android8 is supported !
     
  28. Edge-mt

    Edge-mt

    Joined:
    Aug 4, 2016
    Posts:
    1
    Hi, I'm really hoping that this plugin isn't abandoned since I bought it today for a very specific reason, which zeusrami asked about 2 months ago and there's no answer for it - is there a way to create a daily notification and a certain time?
     
  29. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Added support Android 8+ (channels)
     
  30. josephsaade

    josephsaade

    Joined:
    Apr 18, 2016
    Posts:
    46
    Hello, I just purchased this plugin but I am unable to build.
    I am using Onesignal SDK and other SDKs and getting some conflicts:
    1- The android build now complains about Permission name C2D_MESSAGE

    Code (csharp):
    1. AndroidManifest.xml:13: Error: Permission name C2D_MESSAGE is not unique (appears in both com.merryberries.demo.permission.C2D_MESSAGE and com.merryberries.demo.permission.C2D_MESSAGE) [UniquePermission]
    2.     <permission android:name="com.merryberries.demo.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    2- All other SDKs that have a file values.xml are requiring translations:
    Code (csharp):
    1. Temp/gradleOut/src/main/res/values/strings.xml:3: Error: "app_name" is not translated in "ar" (Arabic), "bg" (Bulgarian), "ca" (Catalan), "cs" (Czech), "de" (German), "es" (Spanish), "fa" (Persian), "fr" (French), "he" (Hebrew), "hr" (Croatian), "id" (Indonesian), "it" (Italian), "ja" (Japanese), "ko" (Korean), "pl" (Polish), "pt" (Portuguese), "pt-BR" (Portuguese: Brazil), "ru" (Russian), "sk" (Slovak), "sl" (Slovenian), "sr" (Serbian), "sv" (Swedish), "th" (Thai), "tr" (Turkish), "uk" (Ukrainian), "vi" (Vietnamese), "zh" (Chinese), "zh-HK" (Chinese: Hong Kong SAR China), "zh-TW" (Chinese: Taiwan) [MissingTranslation]
    2.   <string name="app_name">UnityBundle</string>
    Code (csharp):
    1.  
    2. Temp/gradleOut/TapdaqHyprMX/res/values/values.xml:3: Error: "MSG_PLEASE_FILL_IN_ALL_FIELDS" is not translated in "ar" (Arabic), "bg" (Bulgarian), "ca" (Catalan), "cs" (Czech), "de" (German), "es" (Spanish), "fa" (Persian), "fr" (French), "he" (Hebrew), "hr" (Croatian), "id" (Indonesian), "it" (Italian), "ja" (Japanese), "ko" (Korean), "pl" (Polish), "pt" (Portuguese), "pt-BR" (Portuguese: Brazil), "ru" (Russian), "sk" (Slovak), "sl" (Slovenian), "sr" (Serbian), "sv" (Swedish), "th" (Thai), "tr" (Turkish), "uk" (Ukrainian), "vi" (Vietnamese), "zh" (Chinese), "zh-HK" (Chinese: Hong Kong SAR China), "zh-TW" (Chinese: Taiwan) [MissingTranslation]
    3.     <string name="MSG_PLEASE_FILL_IN_ALL_FIELDS">Please fill in all fields.</string>
    4.  
    The aar provided will conflict with other sdks, it would be great if you can switch to google play resolver dependency system.
     
    Last edited: Dec 19, 2018
  31. josephsaade

    josephsaade

    Joined:
    Apr 18, 2016
    Posts:
    46
    Update:
    I removed all conflicting aars and updated graddle template to ignore translations.

    It builds ands I an receive a scheduled notification but:
    1- Sound never plays (is there a place where I can set the sound?)
    2- The game has to be open (or in background) to receive the notification. Otherwise I get an error message on the android phone ("Appname keeps stopping...")

    Please advise.
     
  32. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Hi.
    Right. If there are conflicts, you can remove aar from the asset.
    1. Need to play a specific sound?
    2. Please send logs. And tell me what is your device and OS version
     
  33. lettucegames

    lettucegames

    Joined:
    Jan 3, 2018
    Posts:
    1
    android 8 version
    Caused by: java.lang.NullPointerException:

    at ru.LittleStories.LocalNotifications.AndroidNativeNotifications.CreateChannel (AndroidNativeNotifications.java:236)

    at ru.LittleStories.LocalNotifications.AndroidNativeNotifications.CheckChannel (AndroidNativeNotifications.java:259)

    at ru.LittleStories.LocalNotifications.AndroidNativeNotifications.onReceive (AndroidNativeNotifications.java:111)
     
  34. Moon_Lady

    Moon_Lady

    Joined:
    Nov 3, 2016
    Posts:
    1
    Hello. Is it possible to specify certian condition, when user clicks on notification, like adding DeepLink link to open instead of opening app? Also, is Unity 2018.2.x supported?
     
  35. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Sorry, need full logs
     
  36. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Hi.
    Need open URL, when user click to notification? I understood correctly?
     
  37. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Added check click on notification.

    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.
     
  38. splitter77

    splitter77

    Joined:
    Feb 25, 2018
    Posts:
    8
    I do not understand why it does not work under ios, even the demo scene does not work.I do not receive notifications
     
  39. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    You allowed "Push Notifications" in "Capabilities"?
     
  40. splitter77

    splitter77

    Joined:
    Feb 25, 2018
    Posts:
    8
  41. splitter77

    splitter77

    Joined:
    Feb 25, 2018
    Posts:
    8
  42. splitter77

    splitter77

    Joined:
    Feb 25, 2018
    Posts:
    8
    any idea ?i just build the demo scene but nothing happens when I run a notification.
     
  43. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    I checked the latest version of the asset, it works for me.
    1. Can you send logs from the device?
    2. What is your version of iOS?
    3. What is your device?
    4. You see prompt about permission to send notifications when starting demo scene?
     
  44. lvladgd

    lvladgd

    Joined:
    Jun 27, 2017
    Posts:
    3
    Hello!
    How can I cancel all scheduled notifications for android?
    For example, if I scheduled notifications in an hour, in two hours and in three hours and the player entered the game on the first notification, then I need to cancel all the others.
    For iOS there is a NotificationServices.CancelAllLocalNotifications(). What about android?
    Thanks!
     
  45. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Hi!
    For cancel all local notifications need run
    LocalNotificationsManager.CancelLocalNotification(idOne);
    LocalNotificationsManager.CancelLocalNotification(idTwo);
    LocalNotificationsManager.CancelLocalNotification(idThree);

    idOne - id for one hour notification, for example, always 1
    idTwo - id for two hour notification, for example, always 2
    idThree - id for three hour notification, for example, always 3

    If the id has already been passed or canceled, it will not create any errors.
    It's work for Android and iOS
     
  46. yusufdemir2012

    yusufdemir2012

    Joined:
    Dec 21, 2013
    Posts:
    13
    Hi. Is plugin support Android P(Android 9)?
     
  47. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
  48. yusufdemir2012

    yusufdemir2012

    Joined:
    Dec 21, 2013
    Posts:
    13
  49. Lucasito

    Lucasito

    Joined:
    Mar 22, 2013
    Posts:
    70
    Thanks for testing!
     
    yusufdemir2012 likes this.
  50. OneLemon

    OneLemon

    Joined:
    Apr 27, 2013
    Posts:
    12
    Hi I just build and ran the apk on my android device. None of the functions seem to be doing anything (send/link/cancel).

    Device Samsung S9
    Android version 9
    Demo scene build in android sdk 28.0.2
    There was no permissions dialog when i first ran the app, I did however allow all permissions manually in the phone settings.
     
unityunity