簡體   English   中英

ios 本地通知 - 擺脫鎖定屏幕上的“通知”文字

[英]ios local notification - get rid of “Notification” text on the lock screen

我正在使用以下代碼顯示本地通知。 當手機未鎖定且應用程序處於后台時,它顯示正常。 但是,當屏幕被鎖定時,它會在字幕下方顯示一個帶有文本Notification的附加行。

由於我的通知沒有body ,無論如何我可以擺脫帶有文本Notification的額外行。 我嘗試將 body 設置nil (盡管 xcode 給出警告)以及空白字符串@""但都沒有幫助。

UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
content.title = title;
content.subtitle = subtitle;
content.body = nil; // warning, also tried @""
content.categoryIdentifier = category;

    
UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:@"LocalNotification" content:content trigger:nil];
    
UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {

}];

知道我在做什么錯嗎?

當用戶將 Show Previews 設置為 When Unlocked 時,您看到的是默認的正文占位符文本。 要更改占位符文本,請使用通知類別並設置其hiddenPreviewsBodyPlaceholder參數。

https://developer.apple.com/documentation/usernotifications/unnotificationcategory/2873733-init

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM