Skip to content

Instantly share code, notes, and snippets.

@RameshAran
Last active September 19, 2016 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RameshAran/6bebf3fb61c73ac4f8b012253756b937 to your computer and use it in GitHub Desktop.
Save RameshAran/6bebf3fb61c73ac4f8b012253756b937 to your computer and use it in GitHub Desktop.
UNMutableNotificationContent* content = [[UNMutableNotificationContent alloc] init];
content.title = [NSString localizedUserNotificationStringForKey:@"Hello!"
arguments:nil];
content.body = [NSString localizedUserNotificationStringForKey:@"Hello_message_body"
arguments:nil];
content.sound = [UNNotificationSound defaultSound];
UNTimeIntervalNotificationTrigger* trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:5
repeats:NO];
UNNotificationRequest *notificationRequest = [UNNotificationRequest requestWithIdentifier:kNotificationIdentifier
content:content
trigger:trigger];
UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
[center addNotificationRequest:notificationRequest
withCompletionHandler:^(NSError * _Nullable error) {
NSLog(@"completed!");
}];
@RameshAran
Copy link
Author

Creating a simple local notification in Objective C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment