0

こんにちは、私は Google カレンダーに取り組んでいます。イベントの開始時に、ローカル通知でユーザー イベントを維持する必要があります。

そのためには、通知を表示する必要があります。ユーザーが一度に2つのイベントを持っている場合、ローカル通知カウントはアプリアイコンで増加する必要があります. .

アプリ アイコンのローカル通知数を増やす方法を教えてください。

私のコードを確認してください。

//Local notifications delegates and methods.
Class cls = NSClassFromString(@"UILocalNotification");

if (cls != nil) {

UILocalNotification *notif = [[cls alloc] init];
notif.fireDate = [[when startTime] date];
notif.timeZone = [NSTimeZone defaultTimeZone];

// Notification details
notif.alertBody =  titles;// here title is the key word for the event

// Set the action button
notif.alertAction = nil;
notif.soundName = UILocalNotificationDefaultSoundName;
notif.applicationIconBadgeNumber = 1;


// Specify custom data for the notification
NSDictionary *userDict = [NSDictionary dictionaryWithObject:titles forKey:kRemindMeNotificationDataKey];

notif.userInfo = userDict;

// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
[notif release];

}

ありがとうございました

4

2 に答える 2

0

私の答えにはデータベースが必要です:

日付とカウントでソートされた配列 (データベース) を作成します。通知が発生したら、そのカウントを呼び出して表示します

[[UIApplication sharedApplication] setApplicationIconBadgeNumber: badgeSortCount]
于 2011-03-12T11:13:12.413 に答える
0

変数 count にアイコンのバッジに表示される正しい数が含まれていると仮定すると、次の操作を行うだけです。

[UIApplication sharedApplication].applicationIconBadgeNumber = count;
于 2011-03-12T06:45:31.940 に答える