0
は、しかし、大きな問題は、私が言うことができ、速報でタイムド通知でバッジを更新していますか?私はちょうど私のアプリにいくつかを追加できるようにコーディング通知を試してきた
something.badge = 3
などでありますしかし、私は言うことができない
something.badge + = 1
または
=バッジ1
something.badgeはこれまでのところ、私のコードは、バッジの数がその特定のであれば、ここでの問題は、私が言って続ける、である。この
よう@IBAction func sendNotification(_ sender: Any) {// in this button you make a notification UIApplication.shared.applicationIconBadgeNumber = 1 let asnwer1 = UNNotificationAction(identifier: "asnwer1", title: "You are", options: UNNotificationActionOptions.foreground) let asnwer2 = UNNotificationAction(identifier: "asnwer2", title: "Obviously you fucking are!" , options: UNNotificationActionOptions.foreground) let category = UNNotificationCategory(identifier: "myCategory", actions: [asnwer1, asnwer2], intentIdentifiers: [], options: []) UNUserNotificationCenter.current().setNotificationCategories([category]) // created nitification let content = UNMutableNotificationContent() content.title = "Are you pathetic for not working out??" content.subtitle = "are you?? " content.body = "Are you sure?" content.categoryIdentifier = "myCategory" /////// THIS NEEDS IMPROVEMENT if UIApplication.shared.applicationIconBadgeNumber == 1{ content.badge = 2 } if UIApplication.shared.applicationIconBadgeNumber == 2{ content.badge = 3 } if UIApplication.shared.applicationIconBadgeNumber == 3{ content.badge = 4 } if UIApplication.shared.applicationIconBadgeNumber == 4{ content.badge = 5 } if UIApplication.shared.applicationIconBadgeNumber == 5{ content.badge = 6 } if UIApplication.shared.applicationIconBadgeNumber == 6{ content.badge = 7 } if UIApplication.shared.applicationIconBadgeNumber == 7{ content.badge = 8 } if UIApplication.shared.applicationIconBadgeNumber >= 8{ content.badge = 9 } let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 10, repeats: false) let request = UNNotificationRequest(identifier: "timerDone", content: content, trigger: trigger) UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)// the previous lne created a let named request...youre using it here }
です番号、それを作る他の特定の番号....それの周りに他の方法はありますか?
「私は 'something.badge + = 1'と言うことはできません」と言うとき、あなたはそれを「言う」ことができないという意味ですか? – lloyd
試してみるときに発生しているエラーを教えてください。 – Digits