UILocalNotification local notification

Source: Internet
Author: User

// To execute the notification, you must exit the application or suspend the application (enter the background) to receive the notification.

// Create a local notification

UILocalNotification *notification = [[UILocalNotification alloc] init];

// Notification trigger time

notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:];

// Notification Time Zone

notification.timeZone = [NSTimeZone defaultTimeZone];

// Notification content

notification.alertBody = ;

// Notification tone

notification.soundName = UILocalNotificationDefaultSoundName;

// Number displayed in the upper-right corner of the application

notification.applicationIconBadgeNumber = ;

// Data dictionary

notification.userInfo = @{: , : @()};

// Start this notification

[[UIApplication sharedApplication] scheduleLocalNotification:notification];

// Enter the foreground and clear the icon in the upper right corner

- ()applicationWillEnterForeground:(UIApplication *

// Click the top notification to enter the application

- ()application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification **alert = [[UIAlertView alloc] initWithTitle: message:notification.userInfo[] :nil cancelButtonTitle:

// Clear all notifications of the current application

[[UIApplication sharedApplication] cancelAllLocalNotifications];

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.