Search Unity

Mobile notifications wrapper gives error on Android

Discussion in 'Scripting' started by AlperGonen, Nov 17, 2019.

  1. AlperGonen

    AlperGonen

    Joined:
    Apr 10, 2019
    Posts:
    6
    Hi, I'm using Unity's mobile notifications wrapper script as shown in here: https://github.com/Unity-Technologies/NotificationsSamples My code is this:
    Code (CSharp):
    1. GameNotificationsManager manager = Camera.main.GetComponent<GameNotificationsManager>();
    2.         var channel = new GameNotificationChannel("default", "Default Game Channel", "Generic notifications");
    3.         if (!manager.Initialized)
    4.         {
    5.             manager.Initialize(channel);
    6.         }
    7.         IGameNotification notification = manager.CreateNotification();
    8.         notification.Title = "Come back!";
    9.         notification.Body = "Your energy is full. Come back and run!";
    10.         //DateTime deliveryTime = DateTime.Now.AddHours(4);
    11.         DateTime deliveryTime = DateTime.Now.AddSeconds(4);
    12.         notification.DeliveryTime = deliveryTime;
    13.         manager.ScheduleNotification(notification);
    When I debug the app on my phone I get this error:
    Code (CSharp):
    1. AndroidJavaException: java.lang.NoSuchMethodError: no non-static method with name='registerNotificationChannel' signature='(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;ZZZZ[II)V' in class Ljava.lang.Object;
    2.     java.lang.NoSuchMethodError: no non-static method with name='registerNotificationChannel' signature='(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;ZZZZ[II)V' in class Ljava.lang.Object;
    3.         at com.unity3d.player.ReflectionHelper.getMethodID(Unknown Source:180)
    4.         at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    5.         at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
    6.         at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
    7.         at android.os.Handler.dispatchMessage(Handler.java:102)
    8.         at android.os.Looper.loop(Looper.java:214)
    9.         at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
    10.       at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0
    11.       at UnityEngine.AndroidJNISafe.CallStaticObjectMethod (System.IntPtr clazz, System.I
    And the notifications doesn't work. I've searched for the error code but couldn't find an answer helping me. Could someone help me about this issue?
     
  2. AlperGonen

    AlperGonen

    Joined:
    Apr 10, 2019
    Posts:
    6
    I have created an empty project and used same code and the outcome is the same as well. I'm using IL2CPP.
    Edit: Issue resolved when I updated to the preview mobile notifications package.
     
    Last edited: Nov 17, 2019
  3. DaniEscribano

    DaniEscribano

    Joined:
    Jan 11, 2019
    Posts:
    1
    You saved my day!!
     
    Gotama and LLIeFs like this.