【发布时间】:2022-11-13 14:46:36
【问题描述】:
我目前正在使用 Unity 的移动通知插件,并开始想知道是否可以在 Anroid 手机上获取新传入通知的信息。
例如:当我的 Unity 应用程序运行时,如果出现另一个应用程序的新通知,是否可以获取它的文本、描述等? 当我尝试它时,我在这里使用了这段代码:
void Start()
{
AndroidNotificationCenter.OnNotificationReceived += receivedNotificationHandler;
}
AndroidNotificationCenter.NotificationReceivedCallback receivedNotificationHandler =
delegate (AndroidNotificationIntentData data)
{
TMP_Text textBox = GameObject.Find("NotificationsInfo").GetComponent<TMP_Text>();
StringBuilder messageBuilder = new StringBuilder()
.AppendLine("Notification received : " + data.Id)
.AppendLine(" .Title: " + data.Notification.Title)
.AppendLine(" .Body: " + data.Notification.Text)
.Append(" .Channel: " + data.Channel);
textBox.text = messageBuilder.ToString();
};
这样,我就可以获取应用程序本身而不是其他应用程序发送的通知信息。有没有办法从其他应用程序获取信息?
【问题讨论】: