Search Unity

Official Mobile Notification Package

Discussion in 'Android' started by _Paulius, Jan 28, 2019.

  1. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    We’ve published a new package in the Preview repo that allows managing Mobile Notifications on Android & iOS directly from Unity.

    It adds support for sending local notifications on Android. On iOS it is intended to replace the NotificationServices API (which has been available in Unity for sometime but uses a deprecated iOS API), and it implements the UserNotifications Framework.

    For both Android and iOS key features are:
    • Schedule notifications with Time, Calendar or a Location(only iOS) triggers (repeatable or one time).
    • Manage notification channels on Android Oreo and above.
    • Cancel scheduled notifications and track their current status (on Android 6.0+).
    • Provide custom icons (on Android).
    • Customize presentation options (on iOS).
    • Implement custom C# callbacks that are triggered when local or push notifications are delivered (push notifications are currently only supported for iOS).
    • Group notifications into threads (on iOS 12+).
    • Change the App’s Icon badge number.
    • Supports Android 4.1+ (API 16) and iOS 10+.

    You can download the Preview package by going to the Package Manager window inside the Unity Editor (the package is available for 2018.3 and above):
    • Click on the ‘Advanced’ button at the top of the window and click on “Show Preview Packages”
    • You should now see the ‘‘Mobile Notifications’ package in the list.

    Alternatively you can just add this to your Packages/manifest.json file:

    Code (JavaScript):
    1.  "dependencies":
    2. {
    3. ...
    4.    "com.unity.mobile.notifications": "1.0.0-preview.13,
    5. ...
    6.   }
    7. }

    You can find the documentation which includes the API reference and some examples here.

    We’ve also produced a Sample Project which implements a high level wrapper that allows sending notifications both to Android and iOS devices with the same API, you can find it on our GitHub page.

    The package is still under development so if you have any feedback or suggestions please post them here. (Alternatively you can also use the Unity bug reporter to submit any bugs or issues you find)
     
    Last edited: Mar 25, 2019
    Kotzman, TechJam, phobos2077 and 4 others like this.
  2. stopiccot_tds

    stopiccot_tds

    Joined:
    Oct 1, 2016
    Posts:
    111
    Taking into account that this package is 2018.2+ only my very first suggestion would be to use java source files instead of precompiled aar.
     
  3. stopiccot_tds

    stopiccot_tds

    Joined:
    Oct 1, 2016
    Posts:
    111
    And moreover I can't actually build project for iOS using Unity 2018.2. I'm getting error:
    Code (csharp):
    1. .../notification_test/Packages/com.unity.mobile.notifications/Runtime/iOS/Plugins/iOS/notifications/UnityNotificationWrapper.m'
    As a workaround I can copy package contents to Assets/Plugins folder.
    here is a github repo to test project https://github.com/stopiccot/notification_test
     
  4. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    @stopiccot_onthespot which 2018.2 version are you using, and did you get the error in Unity or Xcode? I've tried building that project with 2018.2.20f1 and it worked for me.

    Yeah, you are right about java source files, I'm planning to switch to shipping them instead of the prebuilt library in the near future. Initially we planned to support older versions as well which would have made that a bit more complicated.
     
  5. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    Hey nice package, have you plans for remote notification ?
     
  6. studentutu

    studentutu

    Joined:
    Oct 22, 2017
    Posts:
    121
    Hi everyone, we have found a that the Unity Mobile Notifications Package notification does not work when the Application is closed (fully closed application by a user. Any idea if this package support push notifications when the application is not running?
     
  7. TalespinMick

    TalespinMick

    Joined:
    Jul 30, 2018
    Posts:
    4
    It does work, you just have to be careful with which data you pass when scheduling your notification.
    The Android api uses UTC time, whilst the iOS api uses local time.
     
  8. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    Notifications should still work both on iOS and Android when the app is closed, however currently scheduled notifications are not preserved when the device is restarted. But that's a good point, I'll try to make the Android API use local time as well.

    @Sylmerria we don't have any specific plans to support push notifications on Android (but it's something we're considering to implement at some point in the future).
     
  9. Thanitsak

    Thanitsak

    Joined:
    Jan 4, 2016
    Posts:
    117
    There are 6 warning after I downloaded the package. What are these talking about and do I have to fix something?

    /Users/Library/Unity/cache/packages/packages.unity.com/com.unity.mobile.notifications@1.0.0-preview.8/Runtime/Android/AndroidNotificationCenter.cs(482,20): warning CS0414: The private field `Unity.Notifications.Android.AndroidNotificationCenter.AndroidSDK' is assigned but its value is never used

    /Users/Library/Unity/cache/packages/packages.unity.com/com.unity.mobile.notifications@1.0.0-preview.8/Editor/UnityNotificationEditorManager.cs(405,25): warning CS0219: The variable `textXxhdpi' is assigned but its value is never used

    /Users/Library/Unity/cache/packages/packages.unity.com/com.unity.mobile.notifications@1.0.0-preview.8/Editor/UnityNotificationEditorManager.cs(480,17): warning CS0219: The variable `textureFormat' is assigned but its value is never used

    /Users/Library/Unity/cache/packages/packages.unity.com/com.unity.mobile.notifications@1.0.0-preview.8/Editor/UnityNotificationsEditorManagerEditor.cs(36,22): warning CS0414: The private field `Unity.Notifications.UnityNotificationsEditorManagerEditor.identifierLabelText' is assigned but its value is never used

    /Users/Library/Unity/cache/packages/packages.unity.com/com.unity.mobile.notifications@1.0.0-preview.8/Editor/UnityNotificationsEditorManagerEditor.cs(37,22): warning CS0414: The private field `Unity.Notifications.UnityNotificationsEditorManagerEditor.typeLabelText' is assigned but its value is never used

    /Users/boat/Library/Unity/cache/packages/packages.unity.com/com.unity.mobile.notifications@1.0.0-preview.8/Runtime/iOS/iOSNotificationCenter.cs(663,60): warning CS0067: The event `Unity.Notifications.iOS.AuthorizationRequest.OnAuthRequest' is never used

    Much appreciate!
     
  10. TalespinMick

    TalespinMick

    Joined:
    Jul 30, 2018
    Posts:
    4
    @BoatBest You can't fix those warnings yourself as the files can't be accessed by us. If you use a warning as error type system you just have to disable it and clear the warnings, I ran into the same issue.

    PauliusP: "... however currently scheduled notifications are not preserved when the device is restarted."
    If anyone is wondering 'well how do I fix this then', you will just have to save the identifiers of the scheduled notifications in playerprefs and request them the next session, allowing you to cancel them etc.

    For anyone that wants to use this package seriously I suggest you write a generic system that uses wrapper classes that wrap around the android and ios functionality, because how it's set up right now really isn't handy to use and looks like it has been written by three different people. Good luck.
     
    phobos2077 and Thanitsak like this.
  11. studentutu

    studentutu

    Joined:
    Oct 22, 2017
    Posts:
    121
    Sorry for not including the test device Android device - it is Huawei android 6.0. Everything works, but when application if fully closed - no notifications are coming (We are using UTC only time both for IOS and Android).We have tested it on other android devices and they have android 7 or 8 (notification are coming even when closed), same for IOS 10,11,12.
     
  12. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    The warning messages are fixed in 1.0.0-preview9 which should be available in the package manager later today.

    @talespin we already have a cross-platform wrapper available here. But yes I agree that the Android & iOS parts are quite different and to some extent this is intentional: they are supposed to mostly map directly to native APIs. Certain Android specific concepts don't really transfer that well to iOS and this is also partially true the other way around. In the future the wrapper I've linked (or something similar to it) will be included in the package itself.

    @studentutu that's strange, it might be something specific to Android 6.0, could you please submit a bug report with the Unity bug reporter? Please list the devices you've tested on and their OS version and add the script you've used to schedule the notifications if possible.
     
    phobos2077 and Thanitsak like this.
  13. studentutu

    studentutu

    Joined:
    Oct 22, 2017
    Posts:
    121
    Sure, I will also include the Android System settings
     
  14. essoperagma

    essoperagma

    Joined:
    Dec 1, 2016
    Posts:
    6
    Hi.
    Is there a way detect which notification caused the app to launch?
    I would like to pass some custom data to a notification during scheduling that I can later retrieve when user taps that notification. This way, I can redirect user to related screen automatically depending on which notification he tapped.
    Thanks
     
    bramble-operations likes this.
  15. TalespinMick

    TalespinMick

    Joined:
    Jul 30, 2018
    Posts:
    4
    As far as I am aware it is not possible with the current functionalities, what you need for that is deeplinking, you could search around for some other plugins that do support that.
     
  16. dreamer-

    dreamer-

    Joined:
    Dec 9, 2016
    Posts:
    25
    Hi,

    When I tested notifications were not working in android Pie and Oreo devices. I tried setting fireTime to System.DateTime.Now.AddSeconds(10) and System.DateTime.UtcNow.AddSeconds(10).
    The code I used is given below:

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using Unity.Notifications.Android;
    6.  
    7. public class LocalNotificationManager : MonoBehaviour
    8. {
    9.     private AndroidNotificationChannel androidNotificationChannel;
    10.     private const string channelId = "0";
    11.  
    12.     // Use this for initialization
    13.     void Start ()
    14.     {
    15.         DontDestroyOnLoad(gameObject);
    16.     }
    17.  
    18.     private void CreateNotificationChannel()
    19.     {
    20.         androidNotificationChannel = new AndroidNotificationChannel();
    21.         androidNotificationChannel.Id = channelId;
    22.         androidNotificationChannel.Name = "Default Channel";
    23.         androidNotificationChannel.Importance = Importance.High;
    24.         androidNotificationChannel.Description = "Generic notifications";
    25.         AndroidNotificationCenter.RegisterNotificationChannel(androidNotificationChannel);
    26.     }
    27.  
    28.     private void OnApplicationPause(bool pause)
    29.     {
    30.         if(pause)
    31.         {
    32.             SendNotification();
    33.         }
    34.         else
    35.         {
    36.             AndroidNotificationCenter.CancelAllNotifications();
    37.         }
    38.     }
    39.  
    40.     private void SendNotification()
    41.     {
    42.         AndroidNotification notification = new AndroidNotification();
    43.         notification.Title = "Test";
    44.         notification.Text = "Test";
    45.         notification.FireTime = System.DateTime.Now.AddSeconds(10);
    46.  
    47.         int id = AndroidNotificationCenter.SendNotification(notification, channelId);
    48.         Debug.Log("Notification status = " + AndroidNotificationCenter.CheckScheduledNotificationStatus(id));
    49.     }
    50. }
    51.  
    EDIT: I had forgotten to create notification channel. Now it is working.
     
    Last edited: Feb 8, 2019
  17. yonek_idreams

    yonek_idreams

    Joined:
    Sep 10, 2014
    Posts:
    26
    Hi,

    We are building our game with 2017.4.18f xcode 10.1 (10B61) and we did notice today that local push notifications for iOS are not working anymore.

    Is that because of the API being deprecated?
     
  18. MrFigment

    MrFigment

    Joined:
    Jan 5, 2017
    Posts:
    27
    I'm kinda confused how does this works.
    - How do I know the ID of the notification when I clicked?
    - Can I open a scene when somone click the notification?

    The notifications works fine on Android, but when the phone locks and unlocks, the notification doesn't remove when clicked

    Code (CSharp):
    1.     void AndroidNotification()
    2.     {
    3.  
    4.         var c = new AndroidNotificationChannel()
    5.         {
    6.             Id = "channel_id",
    7.             Name = "Default Channel",
    8.             Importance = Importance.High,
    9.             Description = "Generic notifications",
    10.         };
    11.         AndroidNotificationCenter.RegisterNotificationChannel(c);
    12.  
    13.         var notification = new AndroidNotification();
    14.         notification.Title = "Give me some food!";
    15.         notification.Text = "test test test test test test test ";
    16.         notification.FireTime = System.DateTime.Now.AddSeconds(30);
    17.         notification.Color = Color.red;
    18.         notification.Style = NotificationStyle.BigTextStyle;
    19.        
    20.  
    21.         int identifier = AndroidNotificationCenter.SendNotification(notification, "channel_id");
    22.  
    23.         Debug.Log("Identifier: " + identifier.ToString());
    24.  
    25.  
    26.     }
     
  19. dreamer-

    dreamer-

    Joined:
    Dec 9, 2016
    Posts:
    25
    I had forgotten to create notification channel. Now it is working.
     
  20. peterguy3

    peterguy3

    Joined:
    Jan 18, 2015
    Posts:
    1
    Hey,
    Nice and useful package that saves getting something off the asset store. I am getting the same issue as @stopiccot_onthespot. I am using 2018.2.14f1. I was also wondering if Rich notifications are planned for a future release with this as they would be nice to have.
     
  21. Bonich

    Bonich

    Joined:
    Oct 25, 2012
    Posts:
    2
    Hello. Have the same problem on various 18.2 versions.
     
  22. _Adriaan

    _Adriaan

    Joined:
    Nov 12, 2009
    Posts:
    481
    Hey Unity folks,

    I love how simple notifications became because of this package! Aside from the few typos and bugs on the manual page, it was pretty much a 'install package > copy/paste examples > fully working notifications'! Wonderful experience :)

    Are there plans to support:
    - custom sounds?
    - banners and alerts, as described on Apple's website? It seems that the current implementation only allows banners, not alerts.
     
    Last edited: Feb 25, 2019
  23. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    Does this mean that this feature won't be backported to Unity 2017 LTS?
     
  24. CSmochinaArnia

    CSmochinaArnia

    Joined:
    Feb 26, 2018
    Posts:
    7
    Hi,

    For iOS, what is this thread variable when scheduling a notification?

    ThreadIdentifier = thread

    Code (CSharp):
    1. var notification = new iOSNotification()
    2. {
    3.     // You can optionally specify a custom Identifier which can later be
    4.     // used to cancel the notification, if you don't set one, an unique
    5.     // string will be generated automatically.
    6.     Identifier = "_notification_01"
    7.     Title = title,
    8.     Body = "Scheduled at: " + DateTime.Now.ToShortDateString() + " triggered in 5 seconds",
    9.     Subtitle = "This is a subtitle, something, something important...",
    10.     ShowInForeground = true,
    11.     ForegroundPresentationOption = foregoungOption,
    12.     CategoryIdentifier = "category_a",
    13.     ThreadIdentifier = thread,
    14.     Trigger = timeTrigger,
    15. };
     
  25. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    @CSmochinaArnia it maps to the this property. Basically it allows you to group notifications with the same identifier into threads on iOS 12.

    @breban1 Unfotunetely no, in the future this package will only support 2018.3 and above.

    @_Adriaan I'm not sure abouts sounds yet. But we'll look into fixing any issues with alerts in the next version.
     
    breban1 likes this.
  26. dandepeched

    dandepeched

    Joined:
    Feb 22, 2016
    Posts:
    31
    @_Paulius , there is some strange bug in the latest version of this package. Every time I restart Unity, selected icon for Android notifications cannot be used by the package anymore and need to be re-selected again:


    I also noticed that to reproduce issue, Mobile Notification Settings tab should not be on screen before restart.
     
    FlyingSquirrels and TalespinMick like this.
  27. TalespinMick

    TalespinMick

    Joined:
    Jul 30, 2018
    Posts:
    4
    @dandepeched We have the exact same problem. When building this results in grey blobs as icons, meaning we can't build through our build server to make the release build. Big issue.
     
    FlyingSquirrels likes this.
  28. needforbleed

    needforbleed

    Joined:
    Mar 19, 2015
    Posts:
    92
    Getting
    : java.lang.NoSuchMethodError: no static method with name='getNotificationManagerImpl' signature='(Landroid.app.Application;Lcom.google.firebase.MessagingUnityPlayerActivity;)Ljava/lang/Object;' in class Ljava.lang.Object;
    java.lang.NoSuchMethodError: no static method with name='getNotificationManagerImpl' signature='(Landroid.app.Application;Lcom.google.firebase.MessagingUnityPlayerActivity;)Ljava/lang/Object;' in class Ljava.lang.Object;

    with the current version of this package on Android 8.
    Occurs on both physical and emulated device.
     
  29. _Adriaan

    _Adriaan

    Joined:
    Nov 12, 2009
    Posts:
    481
    I guess I wasn't clear enough on this: Banners and Alerts are different kinds of notifications in the Apple ecosystem. They behave differently. For example: one disappears from the screen automatically, while the other requires an action (like... 'snooze'). I would love to see the option between these two types added to the Mobile Notification Package. This functionality isn't 'broken', it's simply missing.

    Custom sounds are a common feature in some of the notification plugins on the Asset Store, so I don't believe it's hard to do. I would much rather use a continuously supported notification plugin from Unity than one from the Asset Store.
     
  30. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    @needforbleed which Unity version are you using?

    I've tried it on a Pixel 2 with 8.1 and 2018.3.8f1 and it seems to work fine.
     
  31. theanhchu

    theanhchu

    Joined:
    Apr 25, 2016
    Posts:
    2
    Can we somehow add some custom contents to the notifications and retrieve them when user click on a notification and open the game?

    For example, clicking on a notification with content : "gem=100" will reward user 100 gems after the game is opened.
     
  32. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    Yeah, it will be possible to set custom data on a notification and retrieve it when that notification is used to open the app in the next version. It should be out at some point next week.
     
  33. dandepeched

    dandepeched

    Joined:
    Feb 22, 2016
    Posts:
    31
    @_Paulius
    After latest update following error appears in console:
    Assembly has reference to non-existent assembly 'GUID:1e8e55397bd004beaba78a667566665f' (Packages/com.unity.mobile.notifications/Editor/Unity.Mobile.Notifications.Editor.asmdef)

    Reinstalling package does not resolve it
     
  34. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    @dandepeched yeah there seems to be an issue with preview.10, thanks for bringing this up, it will be fixed in the next release later this week. For now please use preview.9 instead.
     
  35. vasanthbalaji

    vasanthbalaji

    Joined:
    Nov 15, 2014
    Posts:
    34
    @_Paulius
    NotificationTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, userHours, userMinutes, 00);
    DateTime NextDate = NotificationTime.AddDays(1);
    TimeSpan NextDayTime=NextDate.TimeOfDay;

    AndroidNotification notification = new AndroidNotification();

    notification.Title = "Todays Time " + DateTime.Now;
    notification.Text ="NotificatonTime"+ NextDayTime;
    notification.FireTime = NotificationTime;
    notification.RepeatInterval = NextDayTime;
    AndroidNotificationCenter.SendNotification(notification, WorkoutchannelId);

    Im not getting Notification for Next day for same time if i put the repeat interval logic time, it works on android nougat but not on oreo or pie, can somebody tell me how to get repeat notification for next day on same time.
     
    Last edited: Mar 25, 2019
  36. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    We've released 1.0.0-preview.13 last week.

    Improvements & changes:

    • [Android] Added an option to reshedule all non expired notification on device restart.
    • [Android] Added a data field to notification object and a method to retrieve the data assigned to a notification that was used to open the app or bring it back from background
    • Changed the minimum Unity version supported by the package to 2018.3.

    Fixes:
    • Notification settings should no longer dissapear if Unity is closed while settings editor screen is not opened

    It's only available on 2018.3 and above.
     
  37. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    @vasanthbalaji I've not seen this, does this also happen with one time notifications (if you've tried)? Could you open a bug report in in the Unity editor (please past or link this code snippet there).
     
  38. vasanthbalaji

    vasanthbalaji

    Joined:
    Nov 15, 2014
    Posts:
    34
    @_Paulius
    OneTime Notification is working properly on Android 7,8,and 9 versions.But Repeat Notifications is not working in oreo and pie

    Have submitted the bug report.
     
    Last edited: Mar 25, 2019
  39. SviperSniper

    SviperSniper

    Joined:
    Mar 1, 2017
    Posts:
    37
    Hey Paulius,
    currently it seems like it is not possible to group notifications on android. Will the support be added in the near future?

    So far the package looks very promising :)

    Thanks in advance!
     
  40. vasanthbalaji

    vasanthbalaji

    Joined:
    Nov 15, 2014
    Posts:
    34
    @_Paulius I have submitted the bug report ,still no reply or updates from your side,waiting for your reply.
     
  41. Deleted User

    Deleted User

    Guest

    @_Paulius Is it possible to send notification while the application is paused?
    In our application I have a secondary thread runnning outside unity that mantains a socket connection alive while it is in background, I'd like to send notification to the user based on the data received by the socket. (It must be realtime, I cannot create in advance a timed notification)

    Everything is working fine with the app in foreground, but a major crash appear when the app in background try to create a notification.
     
  42. ArturSu1

    ArturSu1

    Joined:
    Oct 2, 2017
    Posts:
    10
    @_Paulius I lost notification ids if app is killed. And CancleAllNotifications() does not work. That's why I have to storage scheduled notification ids and cancel them one by one.
     
  43. TorLinn

    TorLinn

    Joined:
    Jan 6, 2018
    Posts:
    2
    Hey. I also have a problem with canceling the notification after restarting the application. I record the message IDs. At run time I can delete notification. But after restarting the application in response to the AndroidNotificationCenter.CheckScheduledNotificationStatus request, i get - "Unknown". And the message is not canceled.

    PS. Sorry. Everything works well! I had a bug with saving the IDs.

    Code (CSharp):
    1.     private void Awake()
    2.     {
    3.         CreateNotificationChannel();
    4.     }
    5.  
    6.     private void CreateNotificationChannel()
    7.     {
    8.         androidNotificationChannel = new AndroidNotificationChannel
    9.         {
    10.             Id = channelId,
    11.             Name = "someID",
    12.             Importance = Importance.Default,
    13.             Description = "Generic notifications",
    14.             EnableLights = true,
    15.             EnableVibration = true,
    16.             LockScreenVisibility = LockScreenVisibility.Public
    17.         };
    18.         AndroidNotificationCenter.RegisterNotificationChannel(androidNotificationChannel);
    19.         Debug.Log($"notification channel - {AndroidNotificationCenter.GetNotificationChannel(channelId).Id}");
    20.     }
    21.  
    22.     public void OnEnable()
    23.     {
    24.         for (int i = notificationBodies.Count - 1; i >= 0 ; i--)
    25.         {
    26.             Debug.Log($"notification status - {AndroidNotificationCenter.CheckScheduledNotificationStatus(notificationBodies[i].id)}");
    27.         }
    28.     }
    29.  
    30.     public void SendNotifitcation(NotificationBody _currentNot)
    31.     {
    32.         PrepareNotification(_currentNot);
    33.  
    34.         AndroidNotification notification = new AndroidNotification();
    35.         notification.Title = localizationDictionarySO.GetLocalizedValueName(_currentNot.notificationType.ToString(), _currentNot.notificationType.ToString());
    36.         notification.Text = localizationDictionarySO.GetLocalizedValueName(_currentNot.additionalInfo.ToString(), _currentNot.additionalInfo.ToString());
    37.         notification.FireTime = DateTime.Now.AddSeconds(_currentNot.delayInSeconds);
    38.         notification.ShouldAutoCancel = true;
    39.         notification.Color = iconColor;
    40.         _currentNot.id = AndroidNotificationCenter.SendNotification(notification, channelId);
    41.         notificationBodies.Add(_currentNot);
    42.     }
     
    Last edited: Mar 29, 2019
    ArturSu1 likes this.
  44. Nola_Totoc

    Nola_Totoc

    Joined:
    Jun 25, 2018
    Posts:
    6
    @_Paulius

    Hi paulius, great work for this package. It's very useful.

    I just have two problems on iOS:

    First, I would like to retrieve the current notification when the app is launched.
    You could retrieve the notification here and save it in a variable: (UnityNotificationManager.m)
    Code (CSharp):
    1. //Called to let your app know which action was selected by the user for a given notification.
    2. -(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler{
    3.  
    4.     completionHandler();
    5.     [[UnityNotificationManager sharedInstance] updateDeliveredNotificationList];
    6. }
    Second, I would like retrieve the userInfo from content in the notification or at least a string to have some custom data (like a deeplink for example) and of course, a field in addition when you create the notification.

    Thx for your job.
     
    Last edited: Apr 2, 2019
  45. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    @SviperSniper thanks for bringing this up, we'll add support for notification groups in the next release.

    @HomeInnovation afaik there is no way to do that. Are you running the secondary thread from Java? If so it might be possible to call the library directly.

    @ArturSu1, thanks for pointing this out, this seems to be a bug, we'll have a fix in the next release.

    @Nola_Totoc we'll try to add support for both of these in the next release.
     
    ArturSu1 and theanhchu like this.
  46. _Adriaan

    _Adriaan

    Joined:
    Nov 12, 2009
    Posts:
    481
  47. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    @_Adriaan sorry forgot to mention this, yeah, we'll look into adding support for alerts as well.
     
  48. Nola_Totoc

    Nola_Totoc

    Joined:
    Jun 25, 2018
    Posts:
    6
    Hi Paulius, thx for all. I'm looking forward for the next release.

    I also noticed an issue on iOS with the function "Initialize" in iOSNotificationCenter.

    Code (CSharp):
    1.         static bool Initialize()
    2.         {
    3.             #if UNITY_EDITOR || !PLATFORM_IOS
    4.                         return false;
    5.             #elif PLATFORM_IOS
    6.  
    7.             if (initialized)
    8.                 return true;
    9.            
    10.             iOSNotificationsWrapper.RegisterOnReceivedCallback();
    11.             return initialized = true;
    12.             #endif
    13.         }
    This function is only called if you call RemoveScheduledNotification, RemoveDeliveredNotification, RemoveAllScheduledNotifications, RemoveAllDeliveredNotifications or ScheduleNotification. The function is private and I can't call manually.
    The problem is that if the application is listening for the notifications (like RemoteNotification) with OnNotificationReceived and you don't call these functions. RegisterOnReceivedCallback is never called.
     
  49. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    @Nola_Totoc thanks, yeah, it seems that it's only properly initialised for `OnRemoteNotificationReceived` but not for `OnNotificationReceived` I'll fix this in the next version.
     
  50. Hien1998

    Hien1998

    Joined:
    Jan 3, 2019
    Posts:
    3
    @_Paulius
    Hi Paulius!!
    how to get callback event click notification to open game??