iOS本地通知(iOS8改变)
2015-01-29 10:34
465 查看
dispatch_async(dispatch_get_main_queue(), ^{
UILocalNotification * localNotification = [[UILocalNotification
alloc] init];
if (localNotification)
{
localNotification.fireDate= [[[NSDate
alloc] init]
dateByAddingTimeInterval:3];
localNotification.timeZone=[NSTimeZone
defaultTimeZone];
localNotification.alertBody =
@"客户端有新的版本,点击到App
Store升级。";
localNotification.alertAction =
@"升级";
localNotification.soundName =
@"";
[application
scheduleLocalNotification:localNotification];
}
});
iOS8中需要在 - (BOOL)application:(UIApplication
*)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法下添加如下代码:
UILocalNotification * localNotification = [[UILocalNotification
alloc] init];
if (localNotification)
{
localNotification.fireDate= [[[NSDate
alloc] init]
dateByAddingTimeInterval:3];
localNotification.timeZone=[NSTimeZone
defaultTimeZone];
localNotification.alertBody =
@"客户端有新的版本,点击到App
Store升级。";
localNotification.alertAction =
@"升级";
localNotification.soundName =
@"";
[application
scheduleLocalNotification:localNotification];
}
});
iOS8中需要在 - (BOOL)application:(UIApplication
*)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法下添加如下代码:
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){ UIUserNotificationType type = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound; UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:type categories:nil]; [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; }
相关文章推荐
- [iOS]在iOS8创建一个交互性强的本地通知
- iOS本地通知和远程通知
- ios本地通知和远程通知
- IOS 本地通知和远程通知
- iOS实现本地通知(local notification)的方法
- IOS实现本地通知
- iOS实现本地通知
- [原]逆向iOS SDK -- “添加本地通知”的流程分析
- iOS学习笔记11—本地通知UILocalNotification
- ios本地通知和远程通知(文章最后有个php服务端实现DEMO)
- iOS学习笔记32—本地通知UILocalNotification
- 【iOS-Cocos2d游戏开发之十六】添加本地通知(UILocalNotification)以及添加系统组件滚动视图(UIScrollView)!【2011年11月15日更新】
- IOS 本地推送通知方法
- IOS 实现本地通知(local notification)的yong法
- ios推送:本地通知UILocalNotification
- iOS本地通知
- ios学习--ios本地通知和远程通知
- iOS中添加/删除本地通知(闹钟)的方法
- iOS学习笔记45—本地通知UILocalNotification
- ios-王云鹤 发送本地通知