UIApplication
extension UIApplication: MoEngageUIApplication
Extension making UIApplication conform to MoEngageUIApplication.
This extension enables the real UIApplication to be used interchangeably
with mock implementations through the protocol abstraction.
-
Implements delegate change observation for
UIApplication.This method wraps the standard KVO API to provide a simpler interface for observing delegate changes.
Declaration
Swift
@MainActor public func observeDelegateChanges( changeHandler: @escaping @Sendable ( _ oldDelegate: UIApplicationDelegate?, _ newDelegate: UIApplicationDelegate? ) -> Void ) -> NSKeyValueObservationParameters
changeHandlerCalled when the delegate property changes.
Return Value
The KVO observation object.
-
Witness for
MoEngageUIApplication/beginMoEngageBackgroundTask(withName:expirationHandler:)that forwards toUIApplication‘s nativebeginBackgroundTask(withName:expirationHandler:).The native expiration handler is non-isolated, so the
@Sendable @MainActorhandleris dispatched throughMoEngageObjectiveCRuntime.executeOnMainto guarantee it runs on the main actor.beginBackgroundTaskitself is safe to call from any thread, so this witness can staynonisolatedand be invoked synchronously from the SDK’s actors.Declaration
Swift
public nonisolated func beginMoEngageBackgroundTask( withName taskName: String?, expirationHandler handler: (@Sendable @MainActor () -> Void)? ) -> UIBackgroundTaskIdentifierParameters
taskNameA descriptive name for the task, used only for debugging.
handlerThe expiration handler, invoked on the main actor before background time expires.
Return Value
The background task token, or
UIBackgroundTaskIdentifier.invalidif the request failed.