Prerequisites
- A working iOS quickstart
- A ready camera session for state observation; an applied package declaring runtime parameters for the parameter-control examples
Active effects and events
Use currentPipelineState as the initial snapshot and observe NosmaiPipelineStateDidChangeNotification for changes. Notifications are coalesced and delivered on the main thread; they are state snapshots, not a guaranteed event for every intermediate setter call.
id pipelineObserver = [[NSNotificationCenter defaultCenter]
addObserverForName:NosmaiPipelineStateDidChangeNotification
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *notification) {
NosmaiPipelineState *snapshot =
notification.userInfo[NosmaiPipelineStateUserInfoKey];
if (snapshot == nil) return;
NSLog(@"Filter=%@, AR=%@, background=%d",
snapshot.activeFilterPath, snapshot.activeEffectPath,
snapshot.backgroundActive);
}];
NosmaiPipelineState *initialState =
[[NosmaiSDK sharedInstance] currentPipelineState];
Replace the log with the app's selection update and render initialState on the same UI owner. The snapshot includes mode, filter and AR paths, background source, and activeBackgroundPackagePath. Use backgroundActive rather than assuming activeBackgroundConfig covers every source; that config describes manual segmentation only.
activeFilterInfo and activeEffectInfo return typed package metadata when available. A built-in sticker can occupy the AR slot without a package path; query isFaceStickerActive for it. For hair colour, use isHairColoringEnabled. Empty package paths do not imply that all manual beauty is disabled.
Other event channels and cleanup
NosmaiEffectsDelegate offers nosmaiEffectsDidChangePipelineState: as an alternative to the notification. Its per-effect load/error callbacks describe package operations; do not use both observation routes to perform the same UI work twice. The SDK's gameEventHandler is for game-package outputs, not all filter operations; see Camera games.
Retain the notification token in the screen owner and remove it during teardown:
[[NSNotificationCenter defaultCenter] removeObserver:pipelineObserver];
Avoid a block retaining its view controller indefinitely: use a weak owner when the block updates controller state. Clear any game handler owned by the screen and ignore work belonging to a retired preview. Pipeline state is not a licence-validity, face-detection, or recording-completion signal.
Read the authored controls
Query parameters only after the package apply completion succeeds:
NSArray<NSDictionary *> *parameters =
[[NosmaiSDK sharedInstance] getEffectParameters] ?: @[];
for (NSDictionary *parameter in parameters) {
NSLog(@"%@ (%@): %@", parameter[@"displayName"],
parameter[@"type"], parameter[@"currentValue"]);
}
Each dictionary can include name, type, displayName, description, currentValue, defaultValue, hasRange, minValue, maxValue, and options. Treat name as an opaque package contract.
Update a value
Use the parameter's declared type. Replace the placeholder with a name returned by getEffectParameters for the active package:
BOOL updated = [[NosmaiSDK sharedInstance]
setEffectParameter:@"AUTHORED_PARAMETER_NAME"
value:0.5f];
BOOL textUpdated = [[NosmaiSDK sharedInstance]
setEffectParameter:@"AUTHORED_TEXT_PARAMETER_NAME"
stringValue:@"Hello"];
if (!updated || !textUpdated) {
NSLog(@"The active package rejected a parameter update");
}
Clamp numeric values to the declared range when hasRange is true. A NO result means the active package did not accept that name, type, or value.
Verify the update
Read the numeric value back with getEffectParameterValue: and confirm the preview changes without reapplying the package. Apply another package and query again; controls belong to the active package and may change completely.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
| The parameter list is empty | No compatible package is active, or the package declares no controls | Wait for successful package application and query again |
The setter returns NO | The name or value type does not match the package metadata | Use the exact returned name and the matching numeric or string setter |
| A slider jumps outside its intended range | The app ignored hasRange, minValue, or maxValue | Build the control from the returned metadata and clamp before setting |