相关疑难解决方法(0)

CloudKit不会将我的徽章计数重置为0

我已经尝试了很多东西,似乎无法重置来自cloudKit的通知的徽章数量.有没有其他人遇到过这个问题.这是我尝试过的:

1)将徽章计数本地设置为0

  application.applicationIconBadgeNumber = 0; (temporarily removes the badge count).
Run Code Online (Sandbox Code Playgroud)

没运气...

2)调用服务器以清除徽章计数

 CKModifyBadgeOperation *oper = [[CKModifyBadgeOperation alloc] initWithBadgeValue:0];
  [oper start];
Run Code Online (Sandbox Code Playgroud)

没运气...

3)拉入所有通知更改并将其全部标记为已读

NSMutableArray *array = [NSMutableArray array];
CKFetchNotificationChangesOperation *operation = [[CKFetchNotificationChangesOperation alloc] initWithPreviousServerChangeToken:nil];
operation.notificationChangedBlock = ^(CKNotification *notification) {
    [array addObject:notification.notificationID];
};
operation.completionBlock = ^{
        CKMarkNotificationsReadOperation *op = [[CKMarkNotificationsReadOperation alloc] initWithNotificationIDsToMarkRead:array];
        [op start];
};
[operation start];
Run Code Online (Sandbox Code Playgroud)

再一次没有运气......

任何建议将不胜感激!谢谢,克里斯

push-notification apple-push-notifications ios8 cloudkit cksubscription

7
推荐指数
1
解决办法
1418
查看次数

Cloudkit:CKNotificationInfo徽章值永不减少

我为cloudkit设置了订阅通知.这是我的代码:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"TRUEPREDICATE"];
    CKSubscription *subscription = [[CKSubscription alloc]
                                    initWithRecordType:recordType
                                    predicate:predicate
                                    options:CKSubscriptionOptionsFiresOnRecordCreation];
    CKNotificationInfo *notificationInfo = [CKNotificationInfo new];
    notificationInfo.alertLocalizationKey =@"New record in cloudKit";
    notificationInfo.shouldBadge = YES;
    notificationInfo.soundName = UILocalNotificationDefaultSoundName;
    notificationInfo.shouldSendContentAvailable = YES;
    subscription.notificationInfo = notificationInfo;
    CKContainer *container = [CKContainer defaultContainer];
    CKDatabase *publicDatabase = [container publicCloudDatabase];
    [publicDatabase saveSubscription:subscription
                   completionHandler:^(CKSubscription *subscription, NSError *error) {
                       if (!error)
                       {
                           NSLog(@"no error");
                       }
                       else
                       {
                           NSLog(@"error%@", error);
                       }

                       }];
Run Code Online (Sandbox Code Playgroud)

工作得很好.问题是徽章,他们看起来像cloudKit没有重置徽章号码,并且即使我将徽章计数设置为零,也会不断增加.

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    application.applicationIconBadgeNumber = 0;
}
Run Code Online (Sandbox Code Playgroud)

当应用程序收到新通知时,从0到5(每个新通知增加1,下一次将是6)

你们中的任何人都知道如何从cloudkit中跟踪正确的徽章数量(在Objective-C中)

iphone ipad icloud cloudkit cknotification

4
推荐指数
1
解决办法
698
查看次数