MoEngageSDKInstanceProvider
public extension MoEngageSDKInstanceProvider
-
Returns
MoEngageSDKInstancebased on the targetDeclaration
Swift
@preconcurrency @MoEngageGlobalActor static func getSDKInstance(workspaceId: String? = nil) -> MoEngageSDKInstance?Parameters
workspaceIdMoEngage Account Identifier
Return Value
MoEngageSDKInstancebelonging to the given account identifier
-
Runs the “SDK must be initialized” guard for the given workspace on the current tracker.
The default tracker calls
fatalErrorwhen the guard fires (seeInitializationTracker/preconditionSDKInitialized(for:)).In test bundles,
MoEngageTestConfigurator(via ObjC+loadinMoEngageTestSupport) callsdisablePreconditionSDKInitialized()at dylib load time — before any test framework starts — so the default tracker never crashes the process during testing.Tests that need to assert the guard fires (e.g.
MoEngageActionCrashGuardTests) bind their own capturing tracker for the duration of the call:await MoEngageSDKInstanceProvider.$initializationTracker.withValue( .init { workspaceId in captured = workspaceId } ) { /* trigger the guarded API */ }Declaration
Swift
public static func preconditionSDKInitialized(_ workspaceId: String?) -
Neutralises the default tracker’s missing-workspace action process-wide by mutating it in place. Called by
MoEngageTestConfiguratorat dylib load time in test bundles.Declaration
Swift
@objc public static func disablePreconditionSDKInitialized() -
Declaration
Swift
public func markInitializationRequested(for workspaceId: String, isDefault: Bool) -
Returns all registered SDK instances as an array.
Note
UsefetchInstances()instead, which returns the instances keyed by workspace ID. Iterate itsvalueswhere an array of instances is required.Declaration
Swift
@available(*, deprecated, message: "Use `fetchInstances(﹚` instead.") @preconcurrency @MoEngageGlobalActor public func fetchInstanceCache() -> [MoEngageSDKInstance]