0
我有以下代碼,它創建一個本地通知,出現在手機的狀態欄中。創建的通知消失後即使我沒有訪問它,也是一小會兒。本地通知消失在手機的狀態欄。如何讓它留在那裏,直到有人訪問它
UILocalNotification *localNotification = [[[UILocalNotification alloc] init] autorelease];
if (!localNotification)
return;
// Current date
NSDate *date = [NSDate date];
// Add one minute to the current time
NSDate *dateToFire = [date dateByAddingTimeInterval:60];
// Set the fire date/time
[localNotification setFireDate:dateToFire];
[localNotification setTimeZone:[NSTimeZone defaultTimeZone]];
localNotification.repeatInterval = 0;
// Create a payload to go along with the notification
NSArray *array = [NSArray arrayWithObjects:@"Value 1", @"Value 2", nil];
NSDictionary *data = [NSDictionary dictionaryWithObject:array forKey:@"payload"];
[localNotification setUserInfo:data];
// Setup alert notification
[localNotification setAlertBody:@"Incoming notification"];
[localNotification setAlertAction:@"Open App"];
[localNotification setHasAction:YES];
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
有人可以幫助我創建一個通知,留在狀態欄,直到用戶訪問它嗎? 謝謝