todotxt / todo.txt-ios

Official Todo.txt iOS app for managing your todo.txt file stored in Dropbox.
http://todotxt.org
GNU General Public License v3.0
379 stars 112 forks source link

badge count frozen #240

Closed ackman678 closed 9 years ago

ackman678 commented 9 years ago

The icon Badge Count is frozen and won't change.

iOS 8.1.1, iPhone 5s

Shows count 3 event though I have Badge Count set to Priority A Tasks, but there are only two Priority A tasks in the file:

img_3257 img_3258 img_3259

Then setting the Badge Count to 'none' doesn't change anything:

img_3261 img_3262

Tried making edits to todo.txt file, but this doesn't force update either:

img_3263 img_3264

Deleting and reinstalling the app through iCloud doesn't fix it either.

ackman678 commented 9 years ago

The error was:

Attempting to badge the application icon but haven't received permission from the user to badge the application

Adding ability to register for the iOS 8 Notifications fixed it as discussed on stackoverflow

Added the following within TodoTxtAppDelegate.m:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // registering for remote notifications
    [self registerForRemoteNotification];

...and

- (void)registerForRemoteNotification {
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
        UIUserNotificationType types = UIUserNotificationTypeSound | UIUserNotificationTypeBadge | UIUserNotificationTypeAlert;
        UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
    } else {
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
    }
}

#ifdef __IPHONE_8_0
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
    [application registerForRemoteNotifications];
}
#endif