You may want to remove one single notification on Notification Center programmatically.

But if the notification is already shown,

it shouldn’t be removed from notification center before user did something.

However, there is a trick to remove it.

At first I’m gonna show you how to remove a UILocalNotification from notification center.

When the notification is already shown on Notification Center, you cannot get that notification with this property.

@property(nonatomic,copy) NSArray *scheduledLocalNotifications;

This property contains notifications which are not shown yet.

That means, you cannot pass notification to call this function

- (void)cancelLocalNotification:(UILocalNotification *)notification;

Therefore you can’t find the notification to remove it from notification center.

OK, now we know that we have to store our LocalNotification Object somewhere and use it to call 


Make a new LocalNotification and set same properties doesn’t help you.

You have to use “NSKeyedArchiver”.

  1. Schedule your notification
    (don’t use “presentLocalNotificationNow:”, if you use it, this process doesn’t work)

    [[UIApplication sharedApplication] scheduleLocalNotification:notification];

  2. Archive notification with path.

    [NSKeyedArchiver archiveRootObject:notification toFile:path];

  3.  And unarchive the notification with path.

    UILocalNotification *noti = [NSKeyedUnarchiver unarchiveObjectWithFile:path];

  4. Then, call cancelLocalNotification with unarchived notification.

    [[UIApplication sharedApplication] cancelLocalNotification:notification];

  5. Remove archived notification from file system

    [[NSFileManager defaultManager] removeItemAtPath:path error:&error];

From now you know how to remove a single local notification from notification center,
and using this process will help you to handle remote notifications.

    1. Send remote notification as “Silent Notification”.

    2. Download Content from your server and create UILocalNotification.
      (or don’t set any value for “alert” key in ‘aps’ paylod and define other key-value pair for your messages or actions and convert it)

    3. Handle the local notification.

You can check sample project in GitHub.

박상건 - gunnih

I think you will agree with this following sentence.

If you want to create new initialiser with some parameter, please don't forget to call '[super init];'.

For example,

- (instancetype)initWithString:(NSString *)string


self = [super init];

if (self) {

self.text = string;


return self;


And now, do you agree with the written code? May be you found already the problem.

In this case, I preffer to call '[self init];'' like following code.

- (instancetype)initWithString:(NSString *)string


self = [self init];

if (self) {

self.text = string;


return self;


because if there can be some initialising in 'init'.

This code will guarantee that your code will not miss some initialising process for this interface.

Someone can make some argument.

"If super class has already that method, you have to call '[super initWithString:];'"

Yes totally right. and in that initialiser of super class, it has to call '[self init];'.

박상건 - gunnih

I found an error with ‘pod install’ after using XCode 6

cannot load such file — xcodeproj/prebuilt/universal.x86_64-darwin14-2.0.0/xcodeproj_ext (LoadError)

(I think it’s kind of commend-line tools conflicts between XCode 5 and 6)

To resolve this problem, we had to re-install CocoaPods with following steps.

1. change command Line Tools version to Xcode 6.0 (XCode -> Preferences -> Locations)

2. remove CocoaPods (yes, you can also remove all other versions)

sudo gem uninstall cocoapods

3. install xcodeproj

sudo gem install xcodeproj

4. re-install CocoaPods

sudo gem install cocoapods

After these steps, run ‘pod install’ in working directory.

pod install

박상건 - gunnih

1 2