//
//  YYNotificationHandler.m
//  YYObjCDemo
//
//  Created by Daniel Bey on 2017年06月21日.
//  Copyright © 2017 百度鹰眼. All rights reserved.
//

#import "YYNotificationHandler.h"

@implementation YYNotificationHandler

-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
    // 应用内展示通知时，角标不增加
    completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound);
}

-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {
    // 简单起见，点击任意一条通知都清空通知并将角标清零
    [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
    [[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications];
}

@end
