void scheduleLocalNotification(int secondsAfter, std::string description ,std::string key)
{
//获取本地推送数组
NSArray *localArray = [[UIApplication sharedApplication] scheduledLocalNotifications];
//声明本地通知对象
// UILocalNotification *localNotification;
if (localArray)
{
for (UILocalNotification *noti in localArray)
{
NSDictionary *dict = noti.userInfo;
if (dict)
{
NSString* strKey = [NSString stringWithCString:key.c_str() encoding:NSUTF8StringEncoding];
NSString *inKey = [dict objectForKey:strKey];
if ([inKey isEqualToString:strKey])
{
return;
}
}
}
}
// if (!localNotification)
{
NSDate *itemDate = [NSDate dateWithTimeIntervalSinceNow:0];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = [itemDate dateByAddingTimeInterval:secondsAfter];
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody = [NSString stringWithUTF8String:description.c_str()];
localNotif.alertAction = NSLocalizedString(@"查看", nil);
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
NSString* strKey = [NSString stringWithCString:key.c_str() encoding:NSUTF8StringEncoding];
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:strKey forKey:strKey];
localNotif.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
}
}