首页 > 其他 > 详细

iOS 本地通知 操作

时间:2014-01-18 18:31:31      阅读:388      评论:0      收藏:0      [点我收藏+]

iOS 本地通知 操作

1:配置通知:然后退出程序;

bubuko.com,布布扣
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = date;  // date after 10 sec from now
localNotif.timeZone = [NSTimeZone defaultTimeZone];

// Notification details
localNotif.alertBody =  text; // text of you that you have fetched
// Set the action button
localNotif.alertAction = @"View";

localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;

// Specify custom data for the notification
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"];
localNotif.userInfo = infoDict;

// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
bubuko.com,布布扣

2:接收通知,打开操作

bubuko.com,布布扣
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Override point for customization after application launch.

// Add the view controller‘s view to the window and display.
[window addSubview:viewController.view];
[window makeKeyAndVisible];

application.applicationIconBadgeNumber = 0;

// Handle launching from a notification
UILocalNotification *localNotif =
[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
    NSLog(@"Recieved Notification %@",localNotif);
}

return YES;
       }

  - (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification  *)notif {
// Handle the notificaton when the app is running
NSLog(@"Recieved Notification %@",notif);
       }
bubuko.com,布布扣

 

参考:http://stackoverflow.com/questions/19357087/how-to-display-notifications-in-status-bar-using-dynamic-data-in-iphone

iOS 本地通知 操作

原文:http://www.cnblogs.com/cocoajin/p/3524934.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!