SnoozeLocalNotification 0.2.0

SnoozeLocalNotification 0.2.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2014年12月

azuakuraru 维护。



Snooze UILocalNotification 库。

安装

用法

您应在 AppDelegate 中添加一些代码。

- (BOOL)application:(UIApplication *) application didFinishLaunchingWithOptions:(NSDictionary *) launchOptions {
    UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    [[SnoozeLocalNotificationCenter center] cancelSnoozeForNotification:localNotif]
    return YES;
}

- (void)applicationWillEnterForeground:(UIApplication *) application {
    [[SnoozeLocalNotificationCenter center] cancelUnnecessarySnooze];
}

并调度 UILocalNotification 和延时。

// Schedule 4 notification.
// fireDate -> 10min -> 30min -> 60min
NSArray *snoozeMinutes = @[@10, @30, @60];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [[NSDate date] dateByAddingTimeInterval:1000];
localNotification.alertBody = @"message";
[[SnoozeLocalNotificationCenter center] schedule:localNotification snoozeMinutes:snoozeMinutes];

API

@interface SnoozeLocalNotificationCenter : NSObject
+ (instancetype)center;
// schedule notification and snooze
- (void)schedule:(UILocalNotification *) snoozeLocalNotification snoozeMinutes:(NSArray *) snoozeMinutes;

// cancel all snooze notifications
- (void)cancelAllSnooze;
// cancel unnecessary notifications.
/* e.g) notificationA -> snoozeX -> snoozeY
 * Notify notificationA, then user launch app.
 * snoozeX and snoozeY are unnecessary notifications.
 */
- (void)cancelUnnecessarySnooze;
// cancel notification and snooze
- (void)cancelSnoozeForNotification:(UILocalNotification *) aNotification;
@end

许可证

SnoozeLocalNotification 在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。