Trying to get android notifications to work
Getting this error: java.lang.ClassNotFoundException: com.unity.androidnotifications.NotificationCallback
My unity version is: 2021.3.19f1
What I have done
- Installed unity mobile notifications package through window/packagemanager, version 2.1.1
- Created Notification Manager class, game object, and attached class to object
- Created an AAB, tested on browser stack
My Code
using System.Collections;
using System.Collections.Generic;
using Unity.Notifications.Android;
using UnityEngine;
public class AndroidNotifs : MonoBehaviour
{
void Start()
{
Debug.Log("Started");
//Create Notifications Channel
var channel = new AndroidNotificationChannel()
{
Id = "channel_id",
Name = "Notifications Channel",
Importance = Importance.Default,
Description = "Reminder notifications",
};
AndroidNotificationCenter.RegisterNotificationChannel(channel);
var notification = new AndroidNotification();
notification.Title = "Your Title";
notification.Text = "Your Text";
notification.FireTime = System.DateTime.Now.AddSeconds(15);
AndroidNotificationCenter.SendNotification(notification, "channel_id");
}
void Update() { }
}
No progress