是否有一种方法可以更改在ios >10的通知区域中文本的显示方式?
例如,目前我正在发送json字符串作为通知,其中包含应用程序所需的信息,并且在锁定屏幕或下拉菜单上的通知区域显示该json字符串。是否有方法自定义在那里显示的文本?
我到处寻找,但我发现的东西没有帮助。当应用程序在前台时,我可以处理通知的显示。
如果不可能,是否可以将通知作为无声通知发送,然后将格式化通知推送到ios通知区域?
我的模板供参考:
const string templateBodyAPNS = "{\"aps\":{\"alert\":\"$(messageParam)\", \"category\": \"test\"}}";我尝试了可变的内容1,也没有工作。
我的分机代码:
using System;
using UIKit;
using UserNotifications;
using UserNotificationsUI;
namespace NotificationContentExtension
{
public partial class NotificationViewController : UIViewController, IUNNotificationContentExtension
{
protected NotificationViewController(IntPtr handle) : base(handle)
{
// Note: this .ctor should not contain any initialization logic.
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Do any required interface initialization here.
}
public void DidReceiveNotification(UNNotification notification)
{
label.Text = "Hello";
new UIAlertView("Received", "Working", null, "Ok").Show();
}
}
}发布于 2018-10-23 23:07:50
您需要将通知服务扩展添加到Xamarin.iOS项目中,以便自定义推送通知的显示方式。
1.在Visual中,转到File/new /Visual#/iOS Exensions/Notification扩展。
如果你还有什么问题请告诉我。
https://stackoverflow.com/questions/52948055
复制相似问题