相关疑难解决方法(0)

如何将本地通知重复间隔设置为自定义时间间隔?

我正在制作一个iPhone应用程序,它需要本地通知.

在本地通知中有repeatInterval属性,我们可以将单位重复间隔设置为分钟,小时,日,周,年等.

我希望重复间隔应该是4个小时.

所以每4小时就有一次本地通知.

我不希望用户为每个设置单独的通知.

我希望用户能够将repeatInterval设置为4小时.

我怎么做?

iphone cocoa-touch ios4 localnotification uilocalnotification

24
推荐指数
4
解决办法
5万
查看次数

每天下午5点重复UILocalNotification

如何在每天下午5点重复UILocalNotification?以下是我设置自定义时间的代码.但我想每天通过自定义通知用户,或者可能是静态时间.我正在使用iOS 6.

    -(void)scheduleNotification{

 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
 [dateFormatter setDateFormat:@"h:mm a"];
NSDate *dateFromString = [[NSDate alloc] init];

dateFromString = [dateFormatter dateFromString:timeStr];

UILocalNotification *localNotif = [[UILocalNotification alloc] init];

if (localNotif == nil)
    return;


localNotif.fireDate = dateFromString;

localNotif.repeatInterval = kCFCalendarUnitDay;
localNotif.timeZone = [NSTimeZone defaultTimeZone];

// Notification details
localNotif.alertBody = @"Reminder is set";
// Set the action button
localNotif.alertAction = @"Ok";

localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;

// Specify custom data for the notification
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Local Push received while …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c ios uilocalnotification

2
推荐指数
1
解决办法
7253
查看次数