Reputation: 114
I am implementing push notifications, which I turn into local notifications in my iOS application.
When the iPhone is locked (Face ID / Touch ID) I see only the notification body which is "Notification" by default.
When the iPhone is unlocked (Face ID / Touch ID) I see the whole notification content.
I have tried to change the alert title to a hardcoded text. Also tried to change the other properties, but I did not manage to solve it out.
This is how I create the local notification:
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.userInfo = dictionary;
[notification setAlertTitle:@"alertTitle"];
[notification setAlertBody:@"alertBody"];
[notification setFireDate:[NSDate date]];
[notification setTimeZone:[NSTimeZone defaultTimeZone]];
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
What I want is - to show the title of the notification despite the locked state of the device, just like WhatsApp does.
As you can see, with the same settings - WhatsApp does show the title even though the iPhone is locked.
Upvotes: 6
Views: 1674
Reputation: 19912
UILocalNotification
is deprecated. You should use the UserNotifications
framework instead.
The notification content is managed by the UNNotificationContent
user which has a subtitle
property in addition to the title
and body
properties. I'm pretty sure the subtitle
property is the one that shows when the phone is locked.
Upvotes: -1
Reputation: 4333
I believe you let the user set this for each app. Go to system settings > Your app > Notifications > Show Previews > Always. Note that you also have a default setting you can change that affects all apps you haven't explicitly configured. Go to system settings > Notifications > Show Previews to change that.
Upvotes: 0