How to create this type of local notification in objective-c.
Asked
Active
Viewed 984 times
-4
-
Please put some code. So, answerer can know which effort you made for it. – girish_pro Jul 31 '17 at 05:51
-
http://prntscr.com/g2ds2r i am able to create local notification like this...I want to know how can i customize its UI. – Neeraj Sonaro Jul 31 '17 at 05:56
-
1You can see Swift code into following tutorial. You need to manage it for Objective-c. https://code.tutsplus.com/tutorials/ios-10-creating-custom-notification-interfaces--cms-27251 – girish_pro Jul 31 '17 at 05:57
-
Thanks...i will check. – Neeraj Sonaro Jul 31 '17 at 06:02
1 Answers
0
Actually if you are setting up a local notification and you're just interested in having an image show up in the notification itself, you don't have to bother with NotificationsUI.framework
UNMutableNotificationContent *content = [UNMutableNotificationContent new];
content.title = @"Title";
content.body = @"Body";
content.sound = [UNNotificationSound defaultSound];
NSURL *imageURL = [NSURL URLWithString:@"file:/some/path/in/app/image.png"];
NSError *error;
UNNotificationAttachment *icon = [UNNotificationAttachment attachmentWithIdentifier:@"image" URL:imageURL options:nil error:&error];
if (error)
{
NSLog(@"error while storing image attachment in notification: %@", error);
}
if (icon)
{
content.attachments = @[icon];
}
Then when the notification appears, the image will show up on the right-hand side of the notification banner like it does for Messages notifications. And you don't have to jump through all of the hoops of setting up a content extension with a categoryIdentifier, etc.

Shahbaz Akram
- 1,598
- 3
- 28
- 45
-
Actually my requirement was to show the notification as shown in the attached image. – Neeraj Sonaro Jul 31 '17 at 06:15