Latest 0.6
Homepage https://github.com/hokuron/HKRLocalNotificationManager
License MIT
Platforms ios , requires ARC

HKRLocalNotificationManager build status

HKRLocalNotificationManager is a safe schedule manager of local notification.

Features

  • Prevents the duplication schedule.
  • Useful methods to schedule.
  • When UILocalNotification is stocked once, and application moved to a background, it is done a schedule all at once.

Installing

CocoaPods

Add the following to your Podfile.

pod 'HKRLocalNotificationManager'

Manual

Add HKRLocalNotificationManager/HKRLocalNotificationManager.{h,m} to your project.

Usage

Scheduling a local notification without action

[[HKRLocalNotificationManager sharedManager] scheduleNotificationOn:specificDate
                                                               body:@"alert body"
                                                           userInfo:nil
                                                            options:nil];

And immediate…

[[HKRLocalNotificationManager sharedManager] presentNotificationNowWithBody:@"alert body"
                                                                   userInfo:nil
                                                                    options:nil];

Scheduling a local notification with action

[[HKRLocalNotificationManager sharedManager] scheduleNotificationWithAction:@"action title"
                                                                     onDate:specificDate
                                                                       body:@"alert body"
                                                                   userInfo:nil
                                                                    options:nil];

And immediate…

[[HKRLocalNotificationManager sharedManager] presentNotificationNowWithAction:@"action title"
                                                                         body:@"alert body"
                                                                     userInfo:nil
                                                                      options:nil];

What is options in arguments?

options in the argument of the above method can specify a value of property of UILocalNotification using NSDictionary.

Example sets the value of applicationIconBadgeNumber using the options.

[[HKRLocalNotificationManager sharedManager] presentNotificationNowWithBody:@"alert body"
                                                                   userInfo:nil
                                                                    options:@{@"applicationIconBadgeNumber": @10}];

Canceling a local notification in system or stacked

If you want to cancel a local notification that you scheduled using the methods above, please do use the following methods always.

[[HKRLocalNotificationManager sharedManager] cancelNotification:specificLocalNotification];
[[HKRLocalNotificationManager sharedManager] cancelAllNotifications];

Set default sound name

You can specify the soundName used in local notification of all. you can also override it using options. defaults to UILocalNotificationDefaultSoundName.

[[HKRLocalNotificationManager sharedManager].defaultSoundName = @"path/to/soundName/file";
[[HKRLocalNotificationManager sharedManager].defaultSoundName = @"path/to/soundName/file";

// soundName of the following local notification is applied nil.
[[HKRLocalNotificationManager sharedManager] presentNotificationNowWithBody:@"alert body"
                                                                   userInfo:nil
                                                                    options:@{@"soundName": [NSNull null]}];

Automatic re-schedule (processing in background)

When UILocalNotification is stocked once, and application moved to a background, it is done a schedule all at once.

// in AppDelegate.m
- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [HKRLocalNotificationManager rescheduleInBackground];
}

Manual re-schedule

[[HKRLocalNotificationManager sharedManager] setNeedsRescheduling];
[[HKRLocalNotificationManager sharedManager] rescheduleAllLocalNotificationsIfNeeded];

License

the MIT license.

Latest podspec

{
    "name": "HKRLocalNotificationManager",
    "version": "0.6",
    "summary": "Safe schedule manager of local notification.",
    "homepage": "https://github.com/hokuron/HKRLocalNotificationManager",
    "license": "MIT",
    "authors": "Takuma Shimizu",
    "platforms": {
        "ios": null
    },
    "source": {
        "git": "https://github.com/hokuron/HKRLocalNotificationManager.git",
        "tag": "v0.6"
    },
    "source_files": "HRKLocalNotificationManager/**/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This