Search Unity

Mobile Notifications

Discussion in 'Assets and Asset Store' started by GleyGames, Nov 13, 2019.

  1. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Mobile Push Notifications
    Keep your players engaged
    Gley-Social.png
    Get it from Asset Store - Mobile Push Notifications
    For detailed implementation instructions see the Documentation


    Key Features:
    • Increase your game engagement by sending notifications.
    • Schedule local notifications with a single line of code.
    • Click callback with custom message for each notification to track app sessions started by notification press.
    • Custom notification icons.
    • Custom notification text.
    • Device restart support.
    • Works for Android and iOS without any changes..
    • Full code and demo scene included.
    • Works with Unity 2019 and above with Free, Plus or Pro license.
    • Requires Mobile Notifications package from Unity.
    Currently supported platforms:
    • Android
    • iOS
    Simple code that works for supported platforms without any change:
    • Initialize Notification Plugin
    Code (CSharp):
    1. void Start()
    2. {
    3.         GleyNotifications.Initialize();
    4.         openText.text=GleyNotifications.AppWasOpenFromNotification();
    5. }
    • Preparing Notification

    Code (CSharp):
    1. /// <summary>
    2. /// Schedule a notification
    3. /// </summary>
    4. /// <param name="title">Title of the notification</param>
    5. /// <param name="text">Content of the notification</param>
    6. /// <param name="timeDelayFromNow">delay to display the notification, this delay will be added to current time</param>
    7. /// <param name="smallIcon">name of the custom small icon from Mobile Notification Settings</param>
    8. /// <param name="largeIcon">name of the custom large icon from Mobile Notification Settings</param>
    9. /// <param name="customData">this data can be retrieved if the users opens app from notification</param>
    10.  
    11. GleyNotifications.SendNotification("Game Title", "Notification body", new System.TimeSpan(hours, minutes, seconds), "small_icon_name", "large_icon_name", "Optional message if app is opened from notification");
    A step by step integration tutorial is available here:

     
    Manuele8838 likes this.
  2. unitynosf

    unitynosf

    Joined:
    Jun 9, 2014
    Posts:
    23
    Hey; looking good!

    Aside from what it seems as understanding of what was really needed as plugin I like the effort with details.
    Will buy for sure.

    Quick question tho; might be a good first question :D

    So, just to be sure, when you say that Initialize() starts up notification channel and cancels all pending notifications, what is then the exact flow or setup that works best if I want to send 1 notification every 24h to the user (or by any similar repeating rule)?

    Thank you!
     
  3. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    We have a complete implementation example in our test scene, but i will explain it to you for a better understanding.
    If you schedule a notification in 24 hours, and your user enters in your app before, lets say 23:59 your user will be inside your app and you want to cancel all pending notifications because your user is already in your app, you do not want him to be notified that something happen in you app, a bonus is available, because he is inside your app and it will know.

    And the implementation goes something like this:
    Code (CSharp):
    1.  private void OnApplicationFocus(bool focus)
    2. {
    3.         if(focus == false)
    4.         {
    5.             //if user left your app schedule all your notifications
    6.             GleyNotifications.SendNotification("Game Title", "App was minimized", new System.TimeSpan(0, 1, 0), null, null, "Opened from Gley Minimized Notification");
    7.         }
    8.         else
    9.         {
    10.             //call initialize when user returns to your app to cancel all pending notifications
    11.             GleyNotifications.Initialize();
    12.         }
    13. }
     
  4. ossang

    ossang

    Joined:
    Aug 2, 2018
    Posts:
    6
    Hi,
    How to send noti at certain time every day?
     
  5. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    Since our plugin is not a server side plugin you have to manually compute that time difference from DateTime.now and DateTime you want to send the notification and schedule the notification using that difference.
     
  6. harunuysali

    harunuysali

    Joined:
    Jan 8, 2017
    Posts:
    2
    Hello,
    I recently buy you plugin but it seems not working properly,
    I downloaded your example app .apk it's working with it but when I do in my project it's not working (like there is something I should do but not mentionet anywhere)
    I just open a new empty project and just added your plugin and build with your example scene = it's not working
    What am I missing ?


    Here is Error code :
    Code (CSharp):
    1. 2020-03-04 17:06:01.890 ? E/Unity: AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='findResourceidInContextByName' signature='(Ljava/lang/Object;Landroid.app.Application;Lcom.unity3d.player.UnityPlayerActivity;)I' in class Lcom.unity.androidnotifications.UnityNotificationManagerOreo;
    2.     java.lang.NoSuchMethodError: no static method with name='findResourceidInContextByName' signature='(Ljava/lang/Object;Landroid.app.Application;Lcom.unity3d.player.UnityPlayerActivity;)I' in class Lcom.unity.androidnotifications.UnityNotificationManagerOreo;
    3.         at com.unity3d.player.ReflectionHelper.getMethodID(Unknown Source:180)
    4.         at com.unity3d.player.UnityPlayer.nativeFocusChanged(Native Method)
    5.         at com.unity3d.player.UnityPlayer.a(Unknown Source:0)
    6.         at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:177)
    7.         at android.os.Handler.dispatchMessage(Handler.java:102)
    8.         at android.os.Looper.loop(Looper.java:201)
    9.         at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
    10.       at UnityEngine._AndroidJNIHelper.GetMethodID (System.
     
    Last edited: Mar 4, 2020
    SanketRJDave likes this.
  7. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    Please follow our youtube tutorial ad it should work. If not let us know.
     
  8. HeathC

    HeathC

    Joined:
    Oct 17, 2016
    Posts:
    110
    Bought your asset... question: on iOS, there is a setting for requesting authorization when the app starts... I don't want that... how do I request authorization later?
     
  9. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
  10. HeathC

    HeathC

    Joined:
    Oct 17, 2016
    Posts:
    110
  11. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    I will add this into our To Do list and it will be added in our next update.
     
    HeathC likes this.
  12. HeathC

    HeathC

    Joined:
    Oct 17, 2016
    Posts:
    110
    Using BOLT I've noticed that when I set up a notification using a time from now unit (as opposed to the timespan unit) it only pushes the last one... is that by design or is that a bug?

    Screen Shot 2020-03-26 at 3.58.33 PM.png
     
  13. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    Are you using the latest version of our plugin?
    Please update the plugin.
     
  14. HeathC

    HeathC

    Joined:
    Oct 17, 2016
    Posts:
    110
    I see that this is fixed in an update to the push asset in ver 1.1.2 by itself but I bought the Mobile Tools package... it says I have the latest version and this update is not there
     
  15. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    We will update mobile tools as well on Monday, and it should be live on asset store in a couple of days. If you need it sooner please write us at gley.assets@gmail.com send us your invoice number and we will send it to you sooner.
    Thank you!
     
    HeathC likes this.
  16. HeathC

    HeathC

    Joined:
    Oct 17, 2016
    Posts:
    110
    Will this be the update that will include the request authorization for push later as opposed to at app start as we discussed earlier in this thread?
     
  17. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    The authorization is not a priority right now, we have more important and urgent issues to deal with right now.
    Thank you for understanding
     
  18. HeathC

    HeathC

    Joined:
    Oct 17, 2016
    Posts:
    110
    Thank you for updating Mobile Tools, that fixed the issue of only one push being scheduled, however, now all my notifications are doubled... two get pushed for every notification
     
  19. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    Please verify your code and make sure it doesn`t run twice.
    If not, you can prepare a test project and send it to us at gley.asset@gmail.com to be able to reproduce your issue. Thank you!
     
  20. HeathC

    HeathC

    Joined:
    Oct 17, 2016
    Posts:
    110
    Turns out on iOS if you have OnAppPause and OnAppQuit going to the same set of checks for what to push, it will come twice... I had to put an init/clear after quit and before the check to clear the pause push... works now... thank you for the update!
     
  21. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Glad you managed to solve your issue. Good luck with your game!
     
    HeathC likes this.
  22. Lampogolovii_

    Lampogolovii_

    Joined:
    Aug 28, 2017
    Posts:
    12
    Hey guys!
    Could you please tell me - can I add a button to a notification? Like play/pause button for my audio player in my game.
    Thanks in advance
     
  23. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    Notification overlaps your current open app, it might be or not your app open.
    I do not know exactly what you are asking.
    If you are asking for custom buttons inside notification popup that is not possible. Inside your game you can do anything you want.
    Please give us more details.
     
  24. Lampogolovii_

    Lampogolovii_

    Joined:
    Aug 28, 2017
    Posts:
    12
    Yes, my question was about button inside notification (I've attached an image). You say that it's not possible. I see. Thanks for your reply!
     

    Attached Files:

  25. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Sorry that is not possible and it will not be in the near future.
     
  26. HeathC

    HeathC

    Joined:
    Oct 17, 2016
    Posts:
    110
    If a user doesn't allow push when they first start the app, what checks can we make to see if they ever allow them again so that the system we build will push if they change their mind?
     
  27. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    You can send the notification as you wish, if the permission is not granted the notification will not show. You do not have to change anything inside your app.
     
  28. BenWilles

    BenWilles

    Joined:
    Mar 9, 2018
    Posts:
    41
    Hi, does this support emojis?
     
  29. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    You can only send strings as parameter when scheduling a notification.
     
  30. HeathC

    HeathC

    Joined:
    Oct 17, 2016
    Posts:
    110
    on ios i had the setting to ask permission at the start of the app, now that I am working on an android version, this never pops up... do we have to ask manually?
     
  31. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    The permission should be automatically added inside android manifest.
    Please check the demo app on the asset store and see if you are able to receive notifications on your testing device.
     
  32. HeathC

    HeathC

    Joined:
    Oct 17, 2016
    Posts:
    110
    what line should I add to the manifest if it isn't there?
     
  33. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    Please send me an email at gley.assets@gmail.com with your invoice number and I will send you a complete working project with notifications integrated.
     
  34. hansadler

    hansadler

    Joined:
    May 12, 2014
    Posts:
    50
    Does this asset support remote push notifications? It appears to only work with local notifications. Thanks.
     
  35. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    This asset only support Local Notifications. You cannot send notifications from a server.
     
  36. kayisoftDev

    kayisoftDev

    Joined:
    Jun 11, 2019
    Posts:
    8
    Hello,

    The asset is nice, and working well, tested on (Note5 Android 6, Gley Mobile Notifictions
    1.1.3, Unity Mobile Notifictions 1.3.2)
    I've two issues please:

    1- On Android, "Reschedule Notifications on Device Restart" is working, and it's sending the Notification after restart

    but if in this case, if I clicked on the notification, nothing happens,
    neither the app opens nor the notification disappears
    The Notification is still there even if clicked on it multiple times

    2- I wanted to use this method
    GleyNotifications.AppWasOpenFromNotification
    inside OnApplicationFocus (not in start)
    to get the information if the player clicked on the notifiction while the app is runing in the background

    the method AppWasOpenFromNotification really returns the correct value if I clicked on a Notifiction while the App is in background

    but after that, try to minimize the App, and come back to it without a notification, the method AppWasOpenFromNotification will return the same value returned previously, while to should return empty string in this case

    to solve this issue: you should clear the value you return in AppWasOpenFromNotification if the app lost focus (OnApplicationFocus, focus=false)


    Best regards
     
    Last edited: Jul 3, 2021
  37. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    About issue 1 I cannot help you because that is a Unity plugin issue, and each phone manufacturer has his own security checks and his own android version and on some devices you need additional permissions but that should be fixed by unity guys in the future.

    About issue 2, that is not an issue. That method should be called only once exactly when you app opens and never again during your app lifetime. So that method works as intended, the first time your app was launched was launched from the notification so if you minimize your app and maximize it again, it was still originally opened from the notification so in my opinion no action is needed. So if you need the behavior that you described you should apply the solution you proposed using your own local variable that resets when OnFocus is called.

    Let me know if you need additional help.
     
  38. unity_tZmCsuMVbRDQmA

    unity_tZmCsuMVbRDQmA

    Joined:
    Aug 17, 2021
    Posts:
    2
    Hi. May be somebody know why new line \n displayed in notification body as \n but now new line here :( even if string is verbatim
     
  39. Hadid

    Hadid

    Joined:
    Jun 12, 2015
    Posts:
    6
    hi there i got a question regarding the plugin! like how do we bring it to unit test in real scenarios like will it support the manual time changing of the device to show the notification because i have checked and it doesnt work that for multiple projects though other plugins do support such thing
     
  40. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,

    The plugin is just a simple wrapper of the official Unity plugin. I just made it more simple to use, not changes are made to the official Unity plugin, so all the functionality of the Unity plugin is the same. The notification time is stored using some external services and some devices might or might not respond correctly to time change, it depends on the manufacturer. Since you are an experienced user that wants to write Unit tests, I think it will be more easy for you to alter the notification time during tests than to change the device time.

    Also I am not sure I understand exactly your question.
     
  41. kayisoftDev

    kayisoftDev

    Joined:
    Jun 11, 2019
    Posts:
    8
    Hello:
    Using Unity 2019.4.35f1
    Unity's mobile notification: 2.0.0

    we are getting this crash on android while initializing



    Non-fatal Exception: java.lang.Exception: AndroidJavaException : java.lang.NoSuchFieldError: no static field with name='EXTRA_BIG_TEXT' signature='Ljava/lang/Object;' in class Landroid/app/Notification;
    at com.unity3d.player.UnityPlayer.nativeRender(com.unity3d.player.UnityPlayer)
    at com.unity3d.player.UnityPlayer.nativeRender(com.unity3d.player.UnityPlayer)
    at com.unity3d.player.UnityPlayer.access$300(com.unity3d.player.UnityPlayer)
    at com.unity3d.player.UnityPlayer$e$1.handleMessage(com.unity3d.player.UnityPlayer$e$1)
    at android.os.Handler.dispatchMessage(android.os.Handler)
    at android.os.Looper.loop(android.os.Looper)
    at com.unity3d.player.UnityPlayer$e.run(com.unity3d.player.UnityPlayer$e)
    at UnityEngine.AndroidJNISafe.CheckException(UnityEngine.AndroidJNISafe)
    at UnityEngine.AndroidJNISafe.GetStaticFieldID(UnityEngine.AndroidJNISafe)
    at UnityEngine._AndroidJNIHelper.GetFieldID(UnityEngine._AndroidJNIHelper)
    at UnityEngine.AndroidJNIHelper.GetFieldID(UnityEngine.AndroidJNIHelper)
    at UnityEngine._AndroidJNIHelper.GetFieldID[ReturnType](UnityEngine._AndroidJNIHelper)
    at UnityEngine.AndroidJavaObject._GetStatic[FieldType](UnityEngine.AndroidJavaObject)
    at Unity.Notifications.Android.AndroidNotificationCenter.Initialize(Unity.Notifications.Android.AndroidNotificationCenter)
    at Unity.Notifications.Android.AndroidNotificationCenter.RegisterNotificationChannel(Unity.Notifications.Android.AndroidNotificationCenter)
    at GleyPushNotifications.NotificationManager.Initialize(GleyPushNotifications.NotificationManager)
    at GleyLocalNotificationPlatform.Init(GleyLocalNotificationPlatform)
     
  42. SangHyun-Park

    SangHyun-Park

    Joined:
    Jan 25, 2017
    Posts:
    5
    Hello.
    I used this code.
    GleyNotifications.SendRepeatNotification(title, text
    , new System.TimeSpan(timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds), new System.TimeSpan(24, 0, 0), null, null, "Test");

    I received first notification. (example after 30 minutes)
    But I don't received after 24 hours in iOS.
    Please help me.
     
  43. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,

    Your field EXTRA_BIG_TEXT is not properly configured. Please check your implementation
     
  44. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,

    I just tested and iOS and the Mobile Notification package from unity does not work anymore. I am waiting for a solution from the Unity devs
     
  45. lemonip00

    lemonip00

    Joined:
    Mar 2, 2021
    Posts:
    1
    If long Text how does it appear on the screen?
    Is Text cut off?
     
  46. peanut23

    peanut23

    Joined:
    Apr 27, 2021
    Posts:
    3
    The text was:
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Massa id neque aliquam vestibulum morbi blandit cursus risus at. Eu volutpat odio facilisis mauris sit amet. Eget egestas purus viverra accumsan in nisl nisi. Integer feugiat scelerisque varius morbi enim nunc faucibus a pellentesque. Id nibh tortor id aliquet. Vitae tempus quam pellentesque nec nam aliquam. Lectus arcu bibendum at varius vel pharetra vel turpis. Quisque id diam vel quam elementum pulvinar etiam non quam. Accumsan in nisl nisi scelerisque. Ipsum a arcu cursus vitae congue mauris rhoncus aenean."

    Here's the result:
    Screenshot_20220420_134218.jpg
    and:
    Screenshot_20220420_134050.jpg
     
  47. Zappyy

    Zappyy

    Joined:
    Jun 9, 2018
    Posts:
    40
    Hello, I tried to build the example (for Android) with Unity 2021 LTS & Mobile Notifications v. 2.0.2. It does not seem to trigger any notifications...
     
  48. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Make sure your selected platform is Android and that you pressed the save button as shown in the image:
    image_2022-08-11_120824992.png
     
  49. Zappyy

    Zappyy

    Joined:
    Jun 9, 2018
    Posts:
    40
    Thank you, I tried many things but this did the trick.
     
    GleyGames likes this.
  50. daveinpublic

    daveinpublic

    Joined:
    May 24, 2013
    Posts:
    167
    Is there a way to make custom noises along with the notifications? For both iOS and Android?