Tip.statusUpdates doesn't fire on event donation

I have a tip that's supposed to be shown after a certain event:

extension Tips {
    static let somethingHappened = Tip.Event(id: "somethingHappened")
}

struct TestTip: Tip {
    let title = Text("Test tip")
    let message = Text("This is a description")

    var rules: [Rule] {
        #Rule(Tips.somethingHappened) { $0.donations.count > 0 }
    }
}

I would like to present this tip when its status becomes .available. To do this, I'm observing statusUpdates in a task:

tipStatusObserverTask = Task { [tip, weak self] in
    print("observing \(tip.id)")

    for await status in tip.statusUpdates {
        guard let self, !Task.isCancelled else {
            return
        }

        print("tip status: \(status)")

        if case .available = status {
            print("will present \(tip.id)")
            displayTip()
        }
    }

    print("done observing \(tip.id)")
}

then I'm donating the event on a button press:

@objc func didPressButton() {
    Tips.somethingHappened.sendDonation {
        print("donated Tips.somethingHappened")
    }
}

The event is donated, but statusUpdates doesn't fire, so the tip never gets shown. The tip appears after I restart the app. What's happening? What am I doing wrong?

statusUpdates fires just fine if the rule is based on a @Parameter change, so I would expect this approach to work for event-based rules.

Here's a project that reproduces the issue in case anyone wants to try: https://www.icloud.com/iclouddrive/085FxcgTPStDSSPoXwh7dx1pQ#TipKitTest

Answered by andrii249 in 816652022

On iOS 18, if I donate the event a few more times the rule is triggered eventually, so the rules are just not reliable, not totally broken.

Reported as FB16040974.

Tip.statusUpdates does fire as expected on iOS 17, so this is probably a regression in iOS 18.

Accepted Answer

On iOS 18, if I donate the event a few more times the rule is triggered eventually, so the rules are just not reliable, not totally broken.

Reported as FB16040974.

Can you please retest this against iOS 18.2? There was a bug in iOS 18.1 that could cause the rules for event donations to fail to re-evaluate immediately!

If the issue is still present in iOS 18.2, please file a feedback for this!

Thank you!

Tip.statusUpdates doesn't fire on event donation
 
 
Q