您当前的位置: 首页 >  ios

培根芝士

暂无认证

  • 0浏览

    0关注

    446博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

iOS10本地通知UNUserNotificationCenter

培根芝士 发布时间:2018-11-07 11:01:37 ,浏览量:0

1,使用UNUserNotificationCenter

(1)创建UNUserNotificationCenter,设置推送模式和代理。


UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert|UNAuthorizationOptionSound|UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error) {
    if (!error) {
        NSLog(@"succeeded!");
    }
}];
center.delegate = self;

(2)设置推送内容

UNMutableNotificationContent *content = [UNMutableNotificationContent new];
content.title = @"推送中心标题";
content.subtitle = @"副标题";
content.body  = @"这是UNUserNotificationCenter信息中心";
content.badge = @20;
content.categoryIdentifier = @"categoryIdentifier";
//        需要解锁显示,红色文字。点击不会进app。
//        UNNotificationActionOptionAuthenticationRequired = (1             
关注
打赏
1660824269
查看更多评论
0.0389s