- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
becomeActiveFirst = YES;
[selfinitLocalNotification];
self.savedOptions = launchOptions;
trueNumber = [[TTCacheUtilobjectFromFile:@"trueNumber.plist"]intValue];
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound];
self.window = [[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]];
// Override point for customization after application launch.
self.home = [[HomeViewControlleralloc] init];
self.navigationController = [[CommonNaviControlleralloc] initWithRootViewController:self.home];
self.window.rootViewController = self.navigationController;
[self.windowmakeKeyAndVisible];
if (!self.user) {
[self showLogin];
}
returnYES;
}
//home页面加载调用
-(int)badgeNumberForLocalNotification
{
shouldNumber = 0;
for (int i=0; i<[totalNotificationArray count]; i++) {
NotificationItem *item=[totalNotificationArrayobjectAtIndex:i];
int period = [self changeToMinisecond:item.time];
if (period < 0) {//小于现在的这个时刻
shouldNumber ++;
}
}
TTLog(@"应被点入的通知个数 %d",shouldNumber);
if ([selfnextDayIsComing]) {
shouldNumber = trueNumber = 0;
[TTCacheUtilwriteObject:[NSStringstringWithFormat:@"%d",trueNumber] toFile:@"trueNumber.plist"];
}
returnshouldNumber - trueNumber;
}
//进入提醒页面时调用
-(void)cleanAndSaveNotificationNubmer:(id)sender
{
trueNumber = shouldNumber;
[TTCacheUtilwriteObject:[NSStringstringWithFormat:@"%d",trueNumber] toFile:@"trueNumber.plist"];
}