Search Unity

Official Mobile Notification Package

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

  1. GamerixTech

    GamerixTech

    Joined:
    Jun 13, 2022
    Posts:
    5
    I checked it on One Plus 9R. I gave all the permissions to the game still the notification isn't coming.
     
  2. Acttogreen

    Acttogreen

    Joined:
    Oct 11, 2015
    Posts:
    2
    Hello, i still facing this bug and got ANR/Crashes on Google Play lately. is there any solution ??

    upload_2022-7-3_15-25-46.png

    java.lang.RuntimeException:
    at android.app.ActivityThread.handleReceiver (ActivityThread.java:3316)
    at android.app.ActivityThread.-wrap20 (ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1715)
    at android.os.Handler.dispatchMessage (Handler.java:102)
    at android.os.Looper.loop (Looper.java:154)
    at android.app.ActivityThread.main (ActivityThread.java:6682)
    at java.lang.reflect.Method.invoke (Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1534)
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1424)
    Caused by: android.content.res.Resources$NotFoundException:
    at android.app.ResourcesManager.createAssetManager (ResourcesManager.java:281)
    at android.app.ResourcesManager.createResourcesImpl (ResourcesManager.java:359)
    at android.app.ResourcesManager.getOrCreateResources (ResourcesManager.java:638)
    at android.app.ResourcesManager.getResources (ResourcesManager.java:730)
    at android.app.ActivityThread.getTopLevelResources (ActivityThread.java:2041)
    at android.app.LoadedApk.getResources (LoadedApk.java:787)
    at android.app.ContextImpl.<init> (ContextImpl.java:2245)
    at android.app.ContextImpl.createApplicationContext (ContextImpl.java:1929)
    at android.content.ContextWrapper.createApplicationContext (ContextWrapper.java:858)
    at android.content.ContextWrapper.createApplicationContext (ContextWrapper.java:858)
    at android.app.Notification$Builder.recoverBuilder (Notification.java:3885)
    at com.unity.androidnotifications.UnityNotificationUtilities.recoverBuilder (UnityNotificationUtilities.java:517)
    at com.unity.androidnotifications.UnityNotificationManager.getNotificationOrBuilderForIntent (UnityNotificationManager.java:879)
    at com.unity.androidnotifications.UnityNotificationManager.onReceive (UnityNotificationManager.java:674)
    at android.app.ActivityThread.handleReceiver (ActivityThread.java:3309)
    at android.app.ActivityThread.-wrap20 (ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1715)
    at android.os.Handler.dispatchMessage (Handler.java:102)
    at android.os.Looper.loop (Looper.java:154)
    at android.app.ActivityThread.main (ActivityThread.java:6682)
    at java.lang.reflect.Method.invoke (Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1534)
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1424)
     
  3. IgorGalimskiFMGames

    IgorGalimskiFMGames

    Joined:
    Jul 21, 2021
    Posts:
    16
    @Aurimas-Cernius

    Hey
    We saw a new issue in version 2.0.2
    'Maximum limit of concurrent alarms 500 reached' It looks like something doesn't work with removing notifications logic. We remove notifications, schedule about 50 notifications and repeat it the next launch. But it looks like removing notifications logic doesn't work, and we exceed the limit in 500 notifications
    We encourage this bug on android 11, 12 Samsung devices only
    Please, check for possible fixes
     

    Attached Files:

    manolis_unity65 likes this.
  4. imaginalis

    imaginalis

    Joined:
    Feb 20, 2015
    Posts:
    29
    CU_Marko and pablo_leban like this.
  5. Badinha

    Badinha

    Joined:
    May 6, 2021
    Posts:
    5
    Our top crash on android right now is this:

    Unity: 2020.3.34f1
    Notification Package: 2.0.2

    Code (CSharp):
    1.  
    2. java.lang.RuntimeException:
    3.   at android.app.ActivityThread.handleReceiver (ActivityThread.java:3018)
    4.   at android.app.ActivityThread.-wrap18 (ActivityThread.java)
    5.   at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1544)
    6.   at android.os.Handler.dispatchMessage (Handler.java:102)
    7.   at android.os.Looper.loop (Looper.java:154)
    8.   at android.app.ActivityThread.main (ActivityThread.java:6077)
    9.   at java.lang.reflect.Method.invoke (Native Method)
    10.   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:865)
    11.   at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:755)
    12. Caused by: android.content.res.Resources$NotFoundException:
    13.   at android.app.ResourcesManager.createAssetManager (ResourcesManager.java:253)
    14.   at android.app.ResourcesManager.createResourcesImpl (ResourcesManager.java:310)
    15.   at android.app.ResourcesManager.getOrCreateResources (ResourcesManager.java:571)
    16.   at android.app.ResourcesManager.getResources (ResourcesManager.java:645)
    17.   at android.app.ActivityThread.getTopLevelResources (ActivityThread.java:1846)
    18.   at android.app.LoadedApk.getResources (LoadedApk.java:766)
    19.   at android.app.ContextImpl.<init> (ContextImpl.java:2066)
    20.   at android.app.ContextImpl.createApplicationContext (ContextImpl.java:1840)
    21.   at android.content.ContextWrapper.createApplicationContext (ContextWrapper.java:792)
    22.   at android.content.ContextWrapper.createApplicationContext (ContextWrapper.java:792)
    23.   at android.app.Notification$Builder.recoverBuilder (Notification.java:3785)
    24.   at com.unity.androidnotifications.UnityNotificationUtilities.recoverBuilder (UnityNotificationUtilities.java:517)
    25.   at com.unity.androidnotifications.UnityNotificationManager.loadSavedNotifications (UnityNotificationManager.java:519)
    26.   at com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver.rescheduleSavedNotifications (UnityNotificationRestartOnBootReceiver.java:26)
    27.   at com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver.onReceive (UnityNotificationRestartOnBootReceiver.java:21)
    28.   at android.app.ActivityThread.handleReceiver (ActivityThread.java:3011)
     
  6. konsnos

    konsnos

    Joined:
    Feb 13, 2012
    Posts:
    121
    The issue with

    Code (CSharp):
    1. iOSNotificationCenter.GetLastRespondedNotification()
    always returning null still persists. Android is working fine.

    Unity 2021.1.12f1
    Mobile Notifications 2.0.2

    This was tested on iPhoneX 15.5 and iPad Air (5th generation) 15.5.

    Also posted that on iOS and tvOS category as I've found this discussion later ( https://forum.unity.com/threads/cant-retrieve-last-notification.1308690/ )
     
  7. korober

    korober

    Joined:
    Jan 20, 2015
    Posts:
    16
    I have same issue. I've submitted the issue. Confirm if you have same issue on the github, please.

    Issue link
     
    Qbit86 likes this.
  8. imaginalis

    imaginalis

    Joined:
    Feb 20, 2015
    Posts:
    29
  9. korober

    korober

    Joined:
    Jan 20, 2015
    Posts:
    16
    If you about this fix, I don't understand why this is not released yet or why pre-release version wasn't submitted.

    When google sees bad (a lot of) crash/nre metric, it drops your position in app ranking in Google Play. Ranking positions affect a money you earn, so a similar issues should be marked as critical I think.
     
    Last edited: Jul 22, 2022
  10. imaginalis

    imaginalis

    Joined:
    Feb 20, 2015
    Posts:
    29
    I agree. I actually mentioned this issue here on March already. This should have been fixed long ago.
     
    korober likes this.
  11. acsoow

    acsoow

    Joined:
    Dec 8, 2020
    Posts:
    2
    Hi Paulius,

    How to expand the notification to be able to push multi line notifications?
     
  12. Tomurtogu

    Tomurtogu

    Joined:
    Nov 30, 2012
    Posts:
    26
    There was a significant increase in crashes after upgrading to v2.0.2

    Unity version 2020.3.34f

    Many crashes due to RemoteServiceException for Android 8 devices

    Code (CSharp):
    1.  
    2. android.app.RemoteServiceException:
    3.   at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1847)
    4.   at android.os.Handler.dispatchMessage (Handler.java:105)
    5.   at android.os.Looper.loop (Looper.java:164)
    6.   at android.app.ActivityThread.main (ActivityThread.java:6695)
    7.   at java.lang.reflect.Method.invoke (Native Method)
    8.   at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240)
    9.   at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:769)
    10.  

    The crash on Android 12 devices still persists.

    Code (CSharp):
    1.  
    2. java.lang.OutOfMemoryError:
    3.   at android.os.Parcel.createString8Array (Parcel.java:1477)
    4.   at android.content.pm.ApplicationInfo.<init> (ApplicationInfo.java:2019)
    5.   at android.content.pm.ApplicationInfo.<init> (ApplicationInfo.java:62)
    6.   at android.content.pm.ApplicationInfo$1.lambda$createFromParcel$0 (ApplicationInfo.java:1988)
    7.   at android.content.pm.ApplicationInfo$1$$ExternalSyntheticLambda0.readRawParceled (Unknown Source)
    8.   at android.os.Parcel.readSquashed (Parcel.java:2122)
    9.   at android.content.pm.ApplicationInfo$1.createFromParcel (ApplicationInfo.java:1988)
    10.   at android.content.pm.ApplicationInfo$1.createFromParcel (ApplicationInfo.java:1985)
    11.   at android.os.Parcel.readParcelable (Parcel.java:3333)
    12.   at android.os.Parcel.readValue (Parcel.java:3226)
    13.   at android.os.Parcel.readArrayMapInternal (Parcel.java:3623)
    14.   at android.os.BaseBundle.initializeFromParcelLocked (BaseBundle.java:292)
    15.   at android.os.BaseBundle.unparcel (BaseBundle.java:236)
    16.   at android.os.Bundle.getParcelable (Bundle.java:1002)
    17.   at android.app.Notification$Builder.recoverBuilder (Notification.java:6397)
    18.   at com.unity.androidnotifications.UnityNotificationUtilities.recoverBuilder (UnityNotificationUtilities.java:517)
    19.   at com.unity.androidnotifications.UnityNotificationManager.loadSavedNotifications (UnityNotificationManager.java:519)
    20.   at com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver.rescheduleSavedNotifications (UnityNotificationRestartOnBootReceiver.java:26)
    21.   at com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver.onReceive (UnityNotificationRestartOnBootReceiver.java:21)
    22.   at android.app.ActivityThread.handleReceiver (ActivityThread.java:4465)
    23.   at android.app.ActivityThread.access$1800 (ActivityThread.java:275)
    24.   at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2179)
    25.   at android.os.Handler.dispatchMessage (Handler.java:106)
    26.   at android.os.Looper.loopOnce (Looper.java:210)
    27.   at android.os.Looper.loop (Looper.java:299)
    28.   at android.app.ActivityThread.main (ActivityThread.java:8280)
    29.   at java.lang.reflect.Method.invoke (Native Method)
    30.   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:576)
    31.   at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1073)
    32.  
     
  13. Tomurtogu

    Tomurtogu

    Joined:
    Nov 30, 2012
    Posts:
    26
    Does anyone intend to do anything about OutOfMemory issue?

    It seems the crash is occuring if Reschedule on Device Restart is on.
    I am going to try to disable it.


    com.unity.androidnotifications.UnityNotificationUtilities.recoverBuilder
    java.lang.OutOfMemoryError


    Code (CSharp):
    1. Exception java.lang.OutOfMemoryError:
    2.   at android.os.Parcel.createString8Array (Parcel.java:1477)
    3.   at android.content.pm.ApplicationInfo.<init> (ApplicationInfo.java:2018)
    4.   at android.content.pm.ApplicationInfo.<init> (ApplicationInfo.java:62)
    5.   at android.content.pm.ApplicationInfo$1.lambda$createFromParcel$0 (ApplicationInfo.java:1985)
    6.   at android.content.pm.ApplicationInfo$1$$ExternalSyntheticLambda0.readRawParceled
    7.   at android.os.Parcel.readSquashed (Parcel.java:2122)
    8.   at android.content.pm.ApplicationInfo$1.createFromParcel (ApplicationInfo.java:1985)
    9.   at android.content.pm.ApplicationInfo$1.createFromParcel (ApplicationInfo.java:1982)
    10.   at android.os.Parcel.readParcelable (Parcel.java:3333)
    11.   at android.os.Parcel.readValue (Parcel.java:3226)
    12.   at android.os.Parcel.readArrayMapInternal (Parcel.java:3623)
    13.   at android.os.BaseBundle.initializeFromParcelLocked (BaseBundle.java:292)
    14.   at android.os.BaseBundle.unparcel (BaseBundle.java:236)
    15.   at android.os.Bundle.getParcelable (Bundle.java:1002)
    16.   at android.app.Notification$Builder.recoverBuilder (Notification.java:6426)
    17.   at com.unity.androidnotifications.UnityNotificationUtilities.recoverBuilder (UnityNotificationUtilities.java:517)
    18.   at com.unity.androidnotifications.UnityNotificationManager.loadSavedNotifications (UnityNotificationManager.java:519)
    19.   at com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver.rescheduleSavedNotifications (UnityNotificationRestartOnBootReceiver.java:26)
    20.   at com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver.onReceive (UnityNotificationRestartOnBootReceiver.java:21)
    21.   at android.app.ActivityThread.handleReceiver (ActivityThread.java:4309)
    22.   at android.app.ActivityThread.access$1600 (ActivityThread.java:248)
    23.   at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2065)
    24.   at android.os.Handler.dispatchMessage (Handler.java:106)
    25.   at android.os.Looper.loopOnce (Looper.java:201)
    26.   at android.os.Looper.loop (Looper.java:288)
    27.   at android.app.ActivityThread.main (ActivityThread.java:7880)
    28.   at java.lang.reflect.Method.invoke
    29.   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
    30.   at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1009)
     
  14. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    Yes, it is being addressed.
     
    Tomurtogu likes this.
  15. Tomurtogu

    Tomurtogu

    Joined:
    Nov 30, 2012
    Posts:
    26
    A new ANR occured on Android 11

    Native method - android.os.MessageQueue.nativePollOnceBroadcast of Intent { cmp=com.xxx.xxx/com.unity.androidnotifications.UnityNotificationManager }
     
  16. BlackEarl

    BlackEarl

    Joined:
    Jul 4, 2016
    Posts:
    2
    Hello. I have a problem with a package. On the android platform, if the application is closed, then pushes do not come or only one comes, the last one scheduled. If the application is open or minimized, then pushes usually come. Also, quite often there are moments when the push is scheduled after a certain time, but in the end it comes late. Device Samsung S21, Platform : Android 12, package 2.0.2.
    I took this code snippet from the forum and used it in an empty project:
    Code (CSharp):
    1.     public void Send(string title, string text, string iconSmall, string iconLarge, int notificationTime, string notificationType)
    2.     {
    3.         AndroidNotificationCenter.SendNotification(new AndroidNotification()
    4.             {
    5.                 Title = title,
    6.                 Text = text,
    7.                 SmallIcon = iconSmall,
    8.                 LargeIcon = iconLarge,
    9.                 FireTime = DateTime.Now.AddSeconds(notificationTime)
    10.             },
    11.             CreateChannels(notificationType));
    12.     }
    13.     private string CreateChannels(string notificationType)
    14.     {
    15.         string channelID = "ChID_" + notificationType;
    16.         var channelDefault = new AndroidNotificationChannel()
    17.         {
    18.             Id = channelID,
    19.             Name = notificationType.ToString(),
    20.             Description = "Default Description",
    21.             Importance = Importance.Default,
    22.         };
    23.         AndroidNotificationCenter.RegisterNotificationChannel(channelDefault);
    24.         return channelID;
    25.     }
     
  17. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    On Android 12 exact scheduling is not yet supported, so the notification will not necessarily come at precise time you scheduled it, it will come around that time.
    There is a special permission introduced on Android 12 that has to be granted by user to support exact timing.

    As for notifications being lost: are they supposed to happen around the same time? If so, they might get batched together, so you only see one appearing and in status bar they are just grouped, since I think 3 is the limit for the same app.
     
  18. BlackEarl

    BlackEarl

    Joined:
    Jul 4, 2016
    Posts:
    2
    Thank you very much, please tell me what kind of resolution you are talking about, to support the exact time? Is it possible to request it using the AndroidManifest or Unity

    Regarding the missing notifications, I'm sure that only one comes, which was the last scheduled or has the longest delay. I used an old self-written plugin for push notifications, when using it when the application is turned off, all notifications arrive, but with a delay, and if the difference between them is small, then, as you said, they are grouped.
     
    Last edited: Aug 12, 2022
  19. CU_Marko

    CU_Marko

    Joined:
    Jan 6, 2022
    Posts:
    7
  20. Tomurtogu

    Tomurtogu

    Joined:
    Nov 30, 2012
    Posts:
    26
    Some fixes have been made in the version on Github. I have been following the release that I published with that version for a few days. I haven't seen any OutOfMemory crashes for now but there are another crashes and ANR's. I have disabled the Reschedule by the way.

    Crash on Android 8.1
    Code (CSharp):
    1. Exception android.app.RemoteServiceException:
    2.   at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1828)
    3.   at android.os.Handler.dispatchMessage (Handler.java:106)
    4.   at android.os.Looper.loop (Looper.java:164)
    5.   at android.app.ActivityThread.main (ActivityThread.java:6647)
    6.   at java.lang.reflect.Method.invoke
    7.   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438)
    8.   at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:811)
    ANR on Android 11

    com.unity.androidnotifications.UnityNotificationManager.notify
    Broadcast of Intent { cmp=com.xx.xx/com.unity.androidnotifications.UnityNotificationManager }
     
  21. IgorGalimskiFMGames

    IgorGalimskiFMGames

    Joined:
    Jul 21, 2021
    Posts:
    16
  22. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    Yes, soon-ish. We are wrapping up all important stuff now, then QA pass. No exact time frame.
     
  23. IgorGalimskiFMGames

    IgorGalimskiFMGames

    Joined:
    Jul 21, 2021
    Posts:
    16
    I faced an issue when notifications don't trigger after move time ahead on android
    It happened with Samsung devices(android 8.10, android 11, android 12)
    No specific pattern, just in one game launch I receive all notifications, in other launch - no
    Different version of the package - 2.0.2 and 2.1.0
     
  24. d2mstudio

    d2mstudio

    Joined:
    Jul 23, 2020
    Posts:
    3
    I imported mobile notification package with version 2.0.2 on Unity 2021.3.11f1. Notification on android phone working perfectly, however I click on notification banner to open app (game) was not woking (Notification banner disappear). Please tell me how to config or fix this error. Appreciate your supporting!
     
  25. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    If you main activity is other than Unity's default, it is recommended to explicitly specify that in the settings. Notifications package tries to figure that out, but that may fail, so better specify explicitly.
     
  26. d2mstudio

    d2mstudio

    Joined:
    Jul 23, 2020
    Posts:
    3
    HI Guy,
    Thanks for your quickly reply. After changed Activity in Notification setting then it worked.
     
  27. imaginalis

    imaginalis

    Joined:
    Feb 20, 2015
    Posts:
    29
  28. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    The package is out already, just not verified for all Unity versions. If you are on version where it's not listed, just modify package manifest file manually.
     
    Qbit86 and imaginalis like this.
  29. aappleBlizz

    aappleBlizz

    Joined:
    Aug 31, 2022
    Posts:
    2
    Are Notification Groups forecasted to be added into the Notifications Manager anytime in the near future?
     
  30. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    Can you elaborate what you are talking about?
     
  31. aappleBlizz

    aappleBlizz

    Joined:
    Aug 31, 2022
    Posts:
    2
  32. IgorGalimskiFMGames

    IgorGalimskiFMGames

    Joined:
    Jul 21, 2021
    Posts:
    16
    @Aurimas-Cernius
    I found an issue with 2.1.0 version
    When I request the permission with PermissionRequest class and swipe away the dialog - the state of permission is
    DeniedDontAskAgain. It sounds wrong - because according to android documentation the status should not change:
    https://developer.android.com/develop/ui/views/notifications/notification-permission#user-swipe-away
    User swipes away from dialog
    If the user swipes away from the dialog—that is, they don't select either allow or don't allow—the state of the notification permission doesn't change.

    Apart from this - when I try to request the permission again - I can't do it, because PermissionRequest class has check for Denied status:
    Code (CSharp):
    1.         public PermissionRequest()
    2.         {
    3.             Status = AndroidNotificationCenter.UserPermissionToPost;
    4.             switch (Status)
    5.             {
    6.                 case PermissionStatus.NotRequested:
    7.                 case PermissionStatus.Denied:
    8.                     Status = PermissionStatus.RequestPending;
    9.                     RequestPermission();
    10.                     break;
    11.             }
    12.         }
    It means - after I swipe away the dialog I can't request the permission anymore
     
  33. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    Could you submit a bug report?
    I think this is not a notification package bug, but rather Unity bug that it reports "Don't ask again".
    As a workaround you can clear the player pref for it, we expose a key for it.
     
  34. IgorGalimskiFMGames

    IgorGalimskiFMGames

    Joined:
    Jul 21, 2021
    Posts:
    16
  35. TillmaniaLtd

    TillmaniaLtd

    Joined:
    Jan 29, 2013
    Posts:
    65
    Getting compile errors with Unity 2019 and 2.1.0:

    Code (CSharp):
    1. Library/PackageCache/com.unity.mobile.notifications@2.1.0/Runtime/Android/NotificationPermission.cs(72,33): error CS0246: The type or namespace name 'PermissionCallbacks' could not be found (are you missing a using directive or an assembly reference?)
     
  36. TillmaniaLtd

    TillmaniaLtd

    Joined:
    Jan 29, 2013
    Posts:
    65
    It seems that version 2.0.2 just flat out doesn't request permission for Notifications on Android 13. There's a fix it seems but only for 2.1.0, but that requires Unity 2020. Im unsure how to proceed, is this going to be fixed for 2019? If so do we have any timescales? Notifications are not a small part of the OS.
     
  37. fengjinnphang

    fengjinnphang

    Joined:
    Apr 15, 2021
    Posts:
    4
    Hello.
    The android notification does not seem to be working with server build. Local build works fine though.
    I am using Unity 2021.3.1f1 and Mobile Notification package 2.0.2 (was using 2.0.0, found the problem, updated to 2.0.2, but still no luck)
    Anyone knows about this issue?
    Thanks in advance.
     
  38. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    That's a very generic statement. Could you elaborate?
     
  39. fengjinnphang

    fengjinnphang

    Joined:
    Apr 15, 2021
    Posts:
    4
    My game will send a notification when player quits the game.
    When I build the apk through local machine, (tried building directly from Unity Editor, and using command line to build), everything works fine. The notification shows up as expected.
    However, when the apk is built through server (which using same command line as mentioned), the notification will not show up. It doesn't seem to have any errors too.
     
  40. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    Is this Unity Cloud build or your own server?
     
  41. fengjinnphang

    fengjinnphang

    Joined:
    Apr 15, 2021
    Posts:
    4
    Not Unity Cloud, I'm using PMEase QuickBuild
     
  42. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    Then, unfortunately, it's up to you find what the configuration difference is between you machine and server.
    I'd start by comparing both apks, if their manifest are the same, but no clue really.
     
  43. IgorGalimskiFMGames

    IgorGalimskiFMGames

    Joined:
    Jul 21, 2021
    Posts:
    16
    Last edited: Dec 7, 2022
  44. fengjinnphang

    fengjinnphang

    Joined:
    Apr 15, 2021
    Posts:
    4
    @Aurimas-Cernius After digging around and comparing files, I still couldn't figure out what's wrong.
    Then I found out the comment of @unity_CC81291D515BDED9C3A7 in https://forum.unity.com/threads/mobile-notifications-not-working.1081022/
    Weirdly, my server build apk able to receive the notification if I did not set FireTime (or set to 1 seconds).
    If I set FireTime (5++ seconds), only local build will receive the notification.
    That being said, for the cases where I set FireTime, from the log, it seems like both local build and server build apk, do send out the notification (SamsungAlarmManager: Send to UID...), but server build apk did not receive it and there is no error or irregular logs about it.

    I'm using Unity 2021.3.1f1, Mobile Notification package 2.0.2.
     
    Last edited: Dec 8, 2022
  45. kole_dole

    kole_dole

    Joined:
    Jul 8, 2018
    Posts:
    8
    Hi,
    I'm writing a simple notification system for Android. On my phone, notification show as I expected, but when I click on notification, my game not opening and notification is still on notification bar. When I click on notification, nothing happens.

    Here is my code:

    Code (CSharp):
    1.         AndroidNotificationChannel channel = new AndroidNotificationChannel()
    2.         {
    3.             Id = "pet_free",
    4.             Name = "Pet Channel",
    5.             Importance = Importance.Default,
    6.             Description = "Generic notifications",
    7.         };
    8.         AndroidNotificationCenter.RegisterNotificationChannel(channel);
    9.  
    10.         AndroidNotification notification = new AndroidNotification();
    11.         notification.Title = "Title";
    12.         notification.Text ="Text";
    13.         notification.SmallIcon = "icon_small";
    14.         notification.LargeIcon = "icon_large";
    15.         notification.FireTime = DateTime.Now.AddMinutes(1);

    Any suggestion?
    Tnx
     

    Attached Files:

  46. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    Do you have a custom activity in your game? If so, go to Project Settings and in Notifications section configure it.
     
  47. kole_dole

    kole_dole

    Joined:
    Jul 8, 2018
    Posts:
    8
    Hi,
    Thanks for reply, I just check my manifest fire and I see Firebase activity is default activity, I guess this is automatically created when I install Firebase plugin

    Code (CSharp):
    1.   <application android:label="@string/app_name" android:icon="@drawable/app_icon">
    2.     <!-- The MessagingUnityPlayerActivity is a class that extends
    3.          UnityPlayerActivity to work around a known issue when receiving
    4.          notification data payloads in the background. -->
    5.     <activity android:name="com.google.firebase.MessagingUnityPlayerActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    6.       <intent-filter>
    7.         <action android:name="android.intent.action.MAIN" />
    8.         <category android:name="android.intent.category.LAUNCHER" />
    9.       </intent-filter>
    10.       <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    11.     </activity>
    12.     <service android:name="com.google.firebase.messaging.MessageForwardingService" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="false"></service>
    13.   </application>
    I will change com.google.firebase.MessagingUnityPlayerActivity as custom activity in Project settings->Notification settings
     
  48. llim_unity

    llim_unity

    Joined:
    Feb 13, 2020
    Posts:
    12
    Hello, we're running package version 2.1.0 and running into an issue where the notifications don't fire/trigger when they are supposed to. For example, we schedule a local notification to fire 5 minutes later, kill the app, nothing happens. But when we relaunch the app the notification shows up (which is very much unintended behaviour). What is weird is that we only experience this on some devices. In others it works flawlessly. It is very much similar behaviour detailed in this thread -> Resolved - Mobile Notifications - Not working ? - Unity Forum

    We would like to confirm if this is a general Android OS thing or if this is a bug in the mobile notifications package. Thank you.
     
  49. IgorGalimskiFMGames

    IgorGalimskiFMGames

    Joined:
    Jul 21, 2021
    Posts:
    16
  50. avinashnx7

    avinashnx7

    Joined:
    Jan 7, 2023
    Posts:
    2
    Hello, I'm facing an issue, I want to set a recurring notification with dynamic content or text.

    For example,
    It's 24 hours since you played... - 1st day notification.
    It's 48 hours since you played... - 2nd day notification.

    I tried AndroidNotificationCenter.NotificationReceivedCallback but it only works when the app is running, but I need this updating in background. I think in native android it can be achieved via broadcast receivers. Is there any way to implement this in Unity?