From def9c0fd066a62ae1579c9b154e729ec2e7c5dec Mon Sep 17 00:00:00 2001 From: Giuseppe Nucifora Date: Fri, 29 Apr 2016 10:26:42 +0200 Subject: [PATCH] - add badge management --- Pod/Classes/PNClasses/PNInstallation.h | 7 ++++++- Pod/Classes/PNClasses/PNInstallation.m | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Pod/Classes/PNClasses/PNInstallation.h b/Pod/Classes/PNClasses/PNInstallation.h index 73b1278..60bd6d5 100644 --- a/Pod/Classes/PNClasses/PNInstallation.h +++ b/Pod/Classes/PNClasses/PNInstallation.h @@ -36,6 +36,11 @@ typedef NS_ENUM(NSInteger, PNInstallationType) { */ - (PNInstallationType) setDeviceTokenFromData:(nullable NSData *)deviceTokenData; +/** + * <#Description#> + */ +- (void) resetBadge; + ///-------------------------------------- #pragma mark - PNInstallation Properties ///-------------------------------------- @@ -75,6 +80,6 @@ typedef NS_ENUM(NSInteger, PNInstallationType) { /** * <#Description#> */ -@property (nonatomic, strong) NSDate *lastUpdate; +@property (nonatomic, strong, readonly, nullable) NSDate *lastUpdate; @end diff --git a/Pod/Classes/PNClasses/PNInstallation.m b/Pod/Classes/PNClasses/PNInstallation.m index a5e099e..2844afd 100644 --- a/Pod/Classes/PNClasses/PNInstallation.m +++ b/Pod/Classes/PNClasses/PNInstallation.m @@ -101,6 +101,18 @@ static bool isFirstAccess = YES; return response; } +- (void) setBadge:(NSInteger)badge { + [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badge]; +} + +- (NSInteger) badge { + return [[UIApplication sharedApplication] applicationIconBadgeNumber]; +} + +- (void) resetBadge { + [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; +} + #pragma mark - #pragma mark Private Methods