{"id":7766,"date":"2025-11-05T08:10:39","date_gmt":"2025-11-05T13:10:39","guid":{"rendered":"https:\/\/stepinto.vision\/?p=7766"},"modified":"2025-11-05T08:10:40","modified_gmt":"2025-11-05T13:10:40","slug":"timelines-working-with-notifications","status":"publish","type":"post","link":"https:\/\/stepinto.vision\/example-code\/timelines-working-with-notifications\/","title":{"rendered":"Timelines: Working with Notifications"},"content":{"rendered":"\n<p>Sending notifications from code to trigger a behavior, and sending notifications from a timeline to trigger code.<\/p>\n\n\n\n<p>We can set up two-way communication between a code and an entity\/timeline from Reality Composer Pro. Let&#8217;s start from the Swift side. We&#8217;ll send a notification that will trigger a behavior, which will run a timeline.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>    func notifyTimeline(_ identifier: String) {\n        if let scene = scene {\n            NotificationCenter.default.post(\n                name: NSNotification.Name(\"RealityKit.NotificationTrigger\"),\n                object: nil,\n                userInfo: &#91;\n                    \"RealityKit.NotificationTrigger.Scene\": scene,\n                    \"RealityKit.NotificationTrigger.Identifier\": identifier\n                &#93;\n            )\n        }\n    }<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #0000FF\">func<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">notifyTimeline<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #795E26\">_<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">identifier<\/span><span style=\"color: #000000\">: <\/span><span style=\"color: #267F99\">String<\/span><span style=\"color: #000000\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        <\/span><span style=\"color: #AF00DB\">if<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">let<\/span><span style=\"color: #000000\"> scene = scene {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            NotificationCenter.<\/span><span style=\"color: #001080\">default<\/span><span style=\"color: #000000\">.<\/span><span style=\"color: #795E26\">post<\/span><span style=\"color: #000000\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                <\/span><span style=\"color: #795E26\">name<\/span><span style=\"color: #000000\">: NSNotification.<\/span><span style=\"color: #795E26\">Name<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;RealityKit.NotificationTrigger&quot;<\/span><span style=\"color: #000000\">),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                <\/span><span style=\"color: #795E26\">object<\/span><span style=\"color: #000000\">: <\/span><span style=\"color: #0000FF\">nil<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                <\/span><span style=\"color: #795E26\">userInfo<\/span><span style=\"color: #000000\">: &#91;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    <\/span><span style=\"color: #A31515\">&quot;RealityKit.NotificationTrigger.Scene&quot;<\/span><span style=\"color: #000000\">: scene,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    <\/span><span style=\"color: #A31515\">&quot;RealityKit.NotificationTrigger.Identifier&quot;<\/span><span style=\"color: #000000\">: identifier<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                &#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            )<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    }<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>notifyTimeline(\"MoveRightMessage\")<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #795E26\">notifyTimeline<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;MoveRightMessage&quot;<\/span><span style=\"color: #000000\">)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>In Reality Composer Pro, we add a Behavior Component to the entity that should receive this. Then we select the Timeline to run.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"756\" data-attachment-id=\"7771\" data-permalink=\"https:\/\/stepinto.vision\/example-code\/timelines-working-with-notifications\/attachment\/step-example-119-03\/\" data-orig-file=\"https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/step-example-119-03.png?fit=2342%2C1730&amp;ssl=1\" data-orig-size=\"2342,1730\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"step-example-119-03\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/step-example-119-03.png?fit=1024%2C756&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/step-example-119-03.png?resize=1024%2C756&#038;ssl=1\" alt=\"\" class=\"wp-image-7771\" srcset=\"https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/step-example-119-03.png?resize=1024%2C756&amp;ssl=1 1024w, https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/step-example-119-03.png?resize=300%2C222&amp;ssl=1 300w, https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/step-example-119-03.png?resize=768%2C567&amp;ssl=1 768w, https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/step-example-119-03.png?resize=1536%2C1135&amp;ssl=1 1536w, https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/step-example-119-03.png?resize=2048%2C1513&amp;ssl=1 2048w, https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/step-example-119-03.png?resize=1200%2C886&amp;ssl=1 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now when we call <code>notifyTimeline(\"MoveRightMessage\")<\/code>, the red sphere will play the MoveRight timeline.<\/p>\n\n\n\n<p>Notice the Notification action at the end of the timeline? We can use this to send another message, this time in the other direction. We just enter an identifier for the notification.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"654\" height=\"454\" data-attachment-id=\"7773\" data-permalink=\"https:\/\/stepinto.vision\/example-code\/timelines-working-with-notifications\/attachment\/reality-composer-pro-2025-11-05-07-26-59\/\" data-orig-file=\"https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/Reality-Composer-Pro-2025-11-05-07.26.59.png?fit=654%2C454&amp;ssl=1\" data-orig-size=\"654,454\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Reality Composer Pro 2025-11-05 07.26.59\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/Reality-Composer-Pro-2025-11-05-07.26.59.png?fit=654%2C454&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/Reality-Composer-Pro-2025-11-05-07.26.59.png?resize=654%2C454&#038;ssl=1\" alt=\"\" class=\"wp-image-7773\" srcset=\"https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/Reality-Composer-Pro-2025-11-05-07.26.59.png?w=654&amp;ssl=1 654w, https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/Reality-Composer-Pro-2025-11-05-07.26.59.png?resize=300%2C208&amp;ssl=1 300w\" sizes=\"auto, (max-width: 654px) 100vw, 654px\" \/><\/figure>\n\n\n\n<p class=\"has-theme-palette-8-background-color has-background\">Note: Reality Composer Pro prompts us to select a Target entity. From what we can tell, this entity is not passed with the other notification data. For consistency, we&#8217;ll select the same entity the other actions used. Technically this action will fire without a Target set, but you may see a warnings in RCP.<\/p>\n\n\n\n<p>We can listen for a <code>RealityKit.NotificationTrigger<\/code> using the <code>onReceive<\/code> modifier. This object contains the scene that sent the notification and the identifier. We can use Scene if we need to do something inside the RealityKit context. We use Identifier to determine what notification was sent.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>.onReceive(NotificationCenter.default.publisher(for: Notification.Name(\"RealityKit.NotificationTrigger\"))) { notification in\n    guard\n        let userInfo = notification.userInfo,\n        let scene = userInfo&#91;\"RealityKit.NotificationTrigger.Scene\"&#93; as? RealityKit.Scene,\n        let identifier = userInfo&#91;\"RealityKit.NotificationTrigger.Identifier\"&#93; as? String\n    else { return }\n\n    switch identifier {\n    case \"ReachedRight\":\n        print(\"Timeline sent: ReachedRight\")\n        isRight = true\n    case \"ReachedLeft\":\n        print(\"Timeline sent: ReachedLeft\")\n        isLeft = true\n    default:\n        print(\"Unknown message from timeline: \\(identifier) in \\(scene)\")\n        break\n    }\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #000000\">.<\/span><span style=\"color: #795E26\">onReceive<\/span><span style=\"color: #000000\">(NotificationCenter.<\/span><span style=\"color: #001080\">default<\/span><span style=\"color: #000000\">.<\/span><span style=\"color: #795E26\">publisher<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #795E26\">for<\/span><span style=\"color: #000000\">: Notification.<\/span><span style=\"color: #795E26\">Name<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;RealityKit.NotificationTrigger&quot;<\/span><span style=\"color: #000000\">))) { notification <\/span><span style=\"color: #AF00DB\">in<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #AF00DB\">guard<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        <\/span><span style=\"color: #0000FF\">let<\/span><span style=\"color: #000000\"> userInfo = notification.<\/span><span style=\"color: #001080\">userInfo<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        <\/span><span style=\"color: #0000FF\">let<\/span><span style=\"color: #000000\"> scene = userInfo&#91;<\/span><span style=\"color: #A31515\">&quot;RealityKit.NotificationTrigger.Scene&quot;<\/span><span style=\"color: #000000\">&#93; as? RealityKit.<\/span><span style=\"color: #001080\">Scene<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        <\/span><span style=\"color: #0000FF\">let<\/span><span style=\"color: #000000\"> identifier = userInfo&#91;<\/span><span style=\"color: #A31515\">&quot;RealityKit.NotificationTrigger.Identifier&quot;<\/span><span style=\"color: #000000\">&#93; as? <\/span><span style=\"color: #267F99\">String<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #AF00DB\">else<\/span><span style=\"color: #000000\"> { <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #AF00DB\">switch<\/span><span style=\"color: #000000\"> identifier {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #AF00DB\">case<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #A31515\">&quot;ReachedRight&quot;<\/span><span style=\"color: #000000\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        <\/span><span style=\"color: #795E26\">print<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;Timeline sent: ReachedRight&quot;<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        isRight = <\/span><span style=\"color: #0000FF\">true<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #AF00DB\">case<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #A31515\">&quot;ReachedLeft&quot;<\/span><span style=\"color: #000000\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        <\/span><span style=\"color: #795E26\">print<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;Timeline sent: ReachedLeft&quot;<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        isLeft = <\/span><span style=\"color: #0000FF\">true<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #AF00DB\">default<\/span><span style=\"color: #000000\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        <\/span><span style=\"color: #795E26\">print<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;Unknown message from timeline: <\/span><span style=\"color: #0000FF\">\\(<\/span><span style=\"color: #000000FF\">identifier<\/span><span style=\"color: #0000FF\">)<\/span><span style=\"color: #A31515\"> in <\/span><span style=\"color: #0000FF\">\\(<\/span><span style=\"color: #000000FF\">scene<\/span><span style=\"color: #0000FF\">)<\/span><span style=\"color: #A31515\">&quot;<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        <\/span><span style=\"color: #AF00DB\">break<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Video Demo<\/h2>\n\n\n\n\t\t<figure class=\"wp-block-jetpack-videopress jetpack-videopress-player\" style=\"\" >\n\t\t\t<div class=\"jetpack-videopress-player__wrapper\"> <div class=\"jetpack-video-wrapper\"><iframe title=\"VideoPress Video Player\" aria-label='VideoPress Video Player' width='720' height='405' src='https:\/\/videopress.com\/embed\/SlXv73xW?cover=1&amp;autoPlay=0&amp;controls=1&amp;loop=0&amp;muted=0&amp;persistVolume=1&amp;playsinline=0&amp;preloadContent=metadata&amp;useAverageColor=1&amp;hd=0' frameborder='0' allowfullscreen data-resize-to-parent=\"true\" allow='clipboard-write'><\/iframe><script src='https:\/\/v0.wordpress.com\/js\/next\/videopress-iframe.js?m=1739540970'><\/script><\/div><\/div>\n\t\t\t\n\t\t\t\n\t\t<\/figure>\n\t\t\n\n\n<h2 class=\"wp-block-heading\">Full Example Code<\/h2>\n\n\n\n<p>Make sure to check out the SimpleTimeline scene in the Reality Composer Pro bundle in the <a href=\"https:\/\/github.com\/radicalappdev\/Step-Into-Example-Code\">repo<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>struct Example119: View {\n    @Environment(\\.realityKitScene) var scene\n\n    @State var isLeft: Bool = true\n    @State var isRight: Bool = false\n\n    var body: some View {\n        RealityView { content in\n            guard let scene = try? await Entity(named: \"SimpleTimeline\", in: realityKitContentBundle) else { return }\n            scene.position.y = -0.4\n            content.add(scene)\n        }\n        .ornament(attachmentAnchor: .scene(.back), ornament: {\n            VStack(spacing: 12) {\n                HStack {\n                    Button(action: {\n                        notifyTimeline(\"MoveLeftMessage\")\n                        isLeft = false\n                        isRight = false\n                    }, label: {\n                        Text(\"MoveLeft\")\n                    })\n\n                    Spacer()\n\n                    Button(action: {\n                        notifyTimeline(\"MoveRightMessage\")\n                        isLeft = false\n                        isRight = false\n                    }, label: {\n                        Text(\"MoveRight\")\n                    })\n                }\n\n                HStack {\n                    Circle()\n                        .fill(isLeft ? .green : .white)\n                        .frame(width: 60, height: 60)\n                    Spacer()\n                    Circle()\n                        .fill(isRight ? .green : .white)\n                        .frame(width: 60, height: 60)\n\n                }\n                .frame(width: 300)\n            }\n            .padding()\n            .glassBackgroundEffect()\n        })\n        \/\/ 2. Timelines can use the Notification action to send a message that we can receive here\n        .onReceive(NotificationCenter.default.publisher(for: Notification.Name(\"RealityKit.NotificationTrigger\"))) { notification in\n            \/\/ We can unpack Scene and Identifier\n            \/\/ We use Identifier to determine what notification was sent\n            \/\/ We can use Scene if we need to do something inside the RealityKit context\n            guard\n                let userInfo = notification.userInfo,\n                let scene = userInfo&#91;\"RealityKit.NotificationTrigger.Scene\"&#93; as? RealityKit.Scene,\n                let identifier = userInfo&#91;\"RealityKit.NotificationTrigger.Identifier\"&#93; as? String\n            else { return }\n\n            switch identifier {\n            case \"ReachedRight\":\n                print(\"Timeline sent: ReachedRight\")\n                isRight = true\n            case \"ReachedLeft\":\n                print(\"Timeline sent: ReachedLeft\")\n                isLeft = true\n            default:\n                print(\"Unknown message from timeline: \\(identifier) in \\(scene)\")\n                break\n            }\n        }\n    }\n\n    \/\/ 1. Send notifications to trigger a behavior on an entity, which will run a timeline\n    func notifyTimeline(_ identifier: String) {\n        if let scene = scene {\n            NotificationCenter.default.post(\n                name: NSNotification.Name(\"RealityKit.NotificationTrigger\"),\n                object: nil,\n                userInfo: &#91;\n                    \"RealityKit.NotificationTrigger.Scene\": scene,\n                    \"RealityKit.NotificationTrigger.Identifier\": identifier\n                &#93;\n            )\n        }\n    }\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #0000FF\">struct<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #267F99\">Example119<\/span><span style=\"color: #000000\">: View {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #0000FF\">@Environment<\/span><span style=\"color: #000000\">(\\.<\/span><span style=\"color: #001080\">realityKitScene<\/span><span style=\"color: #000000\">) <\/span><span style=\"color: #0000FF\">var<\/span><span style=\"color: #000000\"> scene<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #0000FF\">@State<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">var<\/span><span style=\"color: #000000\"> isLeft: <\/span><span style=\"color: #267F99\">Bool<\/span><span style=\"color: #000000\"> = <\/span><span style=\"color: #0000FF\">true<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #0000FF\">@State<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">var<\/span><span style=\"color: #000000\"> isRight: <\/span><span style=\"color: #267F99\">Bool<\/span><span style=\"color: #000000\"> = <\/span><span style=\"color: #0000FF\">false<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #0000FF\">var<\/span><span style=\"color: #000000\"> body: some View {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        RealityView { content <\/span><span style=\"color: #AF00DB\">in<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            <\/span><span style=\"color: #AF00DB\">guard<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">let<\/span><span style=\"color: #000000\"> scene = <\/span><span style=\"color: #AF00DB\">try<\/span><span style=\"color: #000000\">? <\/span><span style=\"color: #AF00DB\">await<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">Entity<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #795E26\">named<\/span><span style=\"color: #000000\">: <\/span><span style=\"color: #A31515\">&quot;SimpleTimeline&quot;<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #795E26\">in<\/span><span style=\"color: #000000\">: realityKitContentBundle) <\/span><span style=\"color: #AF00DB\">else<\/span><span style=\"color: #000000\"> { <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            scene.<\/span><span style=\"color: #001080\">position<\/span><span style=\"color: #000000\">.<\/span><span style=\"color: #001080\">y<\/span><span style=\"color: #000000\"> = <\/span><span style=\"color: #098658\">-0.4<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            content.<\/span><span style=\"color: #795E26\">add<\/span><span style=\"color: #000000\">(scene)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        .<\/span><span style=\"color: #795E26\">ornament<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #795E26\">attachmentAnchor<\/span><span style=\"color: #000000\">: .<\/span><span style=\"color: #795E26\">scene<\/span><span style=\"color: #000000\">(.<\/span><span style=\"color: #001080\">back<\/span><span style=\"color: #000000\">), <\/span><span style=\"color: #795E26\">ornament<\/span><span style=\"color: #000000\">: {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            <\/span><span style=\"color: #795E26\">VStack<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #795E26\">spacing<\/span><span style=\"color: #000000\">: <\/span><span style=\"color: #098658\">12<\/span><span style=\"color: #000000\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                HStack {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    <\/span><span style=\"color: #795E26\">Button<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #795E26\">action<\/span><span style=\"color: #000000\">: {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                        <\/span><span style=\"color: #795E26\">notifyTimeline<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;MoveLeftMessage&quot;<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                        isLeft = <\/span><span style=\"color: #0000FF\">false<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                        isRight = <\/span><span style=\"color: #0000FF\">false<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    }, <\/span><span style=\"color: #795E26\">label<\/span><span style=\"color: #000000\">: {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                        <\/span><span style=\"color: #795E26\">Text<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;MoveLeft&quot;<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    })<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    <\/span><span style=\"color: #795E26\">Spacer<\/span><span style=\"color: #000000\">()<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    <\/span><span style=\"color: #795E26\">Button<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #795E26\">action<\/span><span style=\"color: #000000\">: {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                        <\/span><span style=\"color: #795E26\">notifyTimeline<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;MoveRightMessage&quot;<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                        isLeft = <\/span><span style=\"color: #0000FF\">false<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                        isRight = <\/span><span style=\"color: #0000FF\">false<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    }, <\/span><span style=\"color: #795E26\">label<\/span><span style=\"color: #000000\">: {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                        <\/span><span style=\"color: #795E26\">Text<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;MoveRight&quot;<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    })<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                HStack {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    <\/span><span style=\"color: #795E26\">Circle<\/span><span style=\"color: #000000\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                        .<\/span><span style=\"color: #795E26\">fill<\/span><span style=\"color: #000000\">(isLeft ? .<\/span><span style=\"color: #001080\">green<\/span><span style=\"color: #000000\"> : .<\/span><span style=\"color: #001080\">white<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                        .<\/span><span style=\"color: #795E26\">frame<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #795E26\">width<\/span><span style=\"color: #000000\">: <\/span><span style=\"color: #098658\">60<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #795E26\">height<\/span><span style=\"color: #000000\">: <\/span><span style=\"color: #098658\">60<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    <\/span><span style=\"color: #795E26\">Spacer<\/span><span style=\"color: #000000\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    <\/span><span style=\"color: #795E26\">Circle<\/span><span style=\"color: #000000\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                        .<\/span><span style=\"color: #795E26\">fill<\/span><span style=\"color: #000000\">(isRight ? .<\/span><span style=\"color: #001080\">green<\/span><span style=\"color: #000000\"> : .<\/span><span style=\"color: #001080\">white<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                        .<\/span><span style=\"color: #795E26\">frame<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #795E26\">width<\/span><span style=\"color: #000000\">: <\/span><span style=\"color: #098658\">60<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #795E26\">height<\/span><span style=\"color: #000000\">: <\/span><span style=\"color: #098658\">60<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                .<\/span><span style=\"color: #795E26\">frame<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #795E26\">width<\/span><span style=\"color: #000000\">: <\/span><span style=\"color: #098658\">300<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            .<\/span><span style=\"color: #795E26\">padding<\/span><span style=\"color: #000000\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            .<\/span><span style=\"color: #795E26\">glassBackgroundEffect<\/span><span style=\"color: #000000\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        })<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        <\/span><span style=\"color: #008000\">\/\/ 2. Timelines can use the Notification action to send a message that we can receive here<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        .<\/span><span style=\"color: #795E26\">onReceive<\/span><span style=\"color: #000000\">(NotificationCenter.<\/span><span style=\"color: #001080\">default<\/span><span style=\"color: #000000\">.<\/span><span style=\"color: #795E26\">publisher<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #795E26\">for<\/span><span style=\"color: #000000\">: Notification.<\/span><span style=\"color: #795E26\">Name<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;RealityKit.NotificationTrigger&quot;<\/span><span style=\"color: #000000\">))) { notification <\/span><span style=\"color: #AF00DB\">in<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            <\/span><span style=\"color: #008000\">\/\/ We can unpack Scene and Identifier<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            <\/span><span style=\"color: #008000\">\/\/ We use Identifier to determine what notification was sent<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            <\/span><span style=\"color: #008000\">\/\/ We can use Scene if we need to do something inside the RealityKit context<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            <\/span><span style=\"color: #AF00DB\">guard<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                <\/span><span style=\"color: #0000FF\">let<\/span><span style=\"color: #000000\"> userInfo = notification.<\/span><span style=\"color: #001080\">userInfo<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                <\/span><span style=\"color: #0000FF\">let<\/span><span style=\"color: #000000\"> scene = userInfo&#91;<\/span><span style=\"color: #A31515\">&quot;RealityKit.NotificationTrigger.Scene&quot;<\/span><span style=\"color: #000000\">&#93; as? RealityKit.<\/span><span style=\"color: #001080\">Scene<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                <\/span><span style=\"color: #0000FF\">let<\/span><span style=\"color: #000000\"> identifier = userInfo&#91;<\/span><span style=\"color: #A31515\">&quot;RealityKit.NotificationTrigger.Identifier&quot;<\/span><span style=\"color: #000000\">&#93; as? <\/span><span style=\"color: #267F99\">String<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            <\/span><span style=\"color: #AF00DB\">else<\/span><span style=\"color: #000000\"> { <\/span><span style=\"color: #AF00DB\">return<\/span><span style=\"color: #000000\"> }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            <\/span><span style=\"color: #AF00DB\">switch<\/span><span style=\"color: #000000\"> identifier {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            <\/span><span style=\"color: #AF00DB\">case<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #A31515\">&quot;ReachedRight&quot;<\/span><span style=\"color: #000000\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                <\/span><span style=\"color: #795E26\">print<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;Timeline sent: ReachedRight&quot;<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                isRight = <\/span><span style=\"color: #0000FF\">true<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            <\/span><span style=\"color: #AF00DB\">case<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #A31515\">&quot;ReachedLeft&quot;<\/span><span style=\"color: #000000\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                <\/span><span style=\"color: #795E26\">print<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;Timeline sent: ReachedLeft&quot;<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                isLeft = <\/span><span style=\"color: #0000FF\">true<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            <\/span><span style=\"color: #AF00DB\">default<\/span><span style=\"color: #000000\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                <\/span><span style=\"color: #795E26\">print<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;Unknown message from timeline: <\/span><span style=\"color: #0000FF\">\\(<\/span><span style=\"color: #000000FF\">identifier<\/span><span style=\"color: #0000FF\">)<\/span><span style=\"color: #A31515\"> in <\/span><span style=\"color: #0000FF\">\\(<\/span><span style=\"color: #000000FF\">scene<\/span><span style=\"color: #0000FF\">)<\/span><span style=\"color: #A31515\">&quot;<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                <\/span><span style=\"color: #AF00DB\">break<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #008000\">\/\/ 1. Send notifications to trigger a behavior on an entity, which will run a timeline<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #0000FF\">func<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">notifyTimeline<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #795E26\">_<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">identifier<\/span><span style=\"color: #000000\">: <\/span><span style=\"color: #267F99\">String<\/span><span style=\"color: #000000\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        <\/span><span style=\"color: #AF00DB\">if<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">let<\/span><span style=\"color: #000000\"> scene = scene {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            NotificationCenter.<\/span><span style=\"color: #001080\">default<\/span><span style=\"color: #000000\">.<\/span><span style=\"color: #795E26\">post<\/span><span style=\"color: #000000\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                <\/span><span style=\"color: #795E26\">name<\/span><span style=\"color: #000000\">: NSNotification.<\/span><span style=\"color: #795E26\">Name<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&quot;RealityKit.NotificationTrigger&quot;<\/span><span style=\"color: #000000\">),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                <\/span><span style=\"color: #795E26\">object<\/span><span style=\"color: #000000\">: <\/span><span style=\"color: #0000FF\">nil<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                <\/span><span style=\"color: #795E26\">userInfo<\/span><span style=\"color: #000000\">: &#91;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    <\/span><span style=\"color: #A31515\">&quot;RealityKit.NotificationTrigger.Scene&quot;<\/span><span style=\"color: #000000\">: scene,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                    <\/span><span style=\"color: #A31515\">&quot;RealityKit.NotificationTrigger.Identifier&quot;<\/span><span style=\"color: #000000\">: identifier<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">                &#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">            )<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Sending notifications from code to trigger a behavior, and sending notifications from a timeline to trigger code.<\/p>\n","protected":false},"author":93705089,"featured_media":7767,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_EventAllDay":false,"_EventTimezone":"","_EventStartDate":"","_EventEndDate":"","_EventStartDateUTC":"","_EventEndDateUTC":"","_EventShowMap":false,"_EventShowMapLink":false,"_EventURL":"","_EventCost":"","_EventCostDescription":"","_EventCurrencySymbol":"","_EventCurrencyCode":"","_EventCurrencyPosition":"","_EventDateTimeSeparator":"","_EventTimeRangeSeparator":"","_EventOrganizerID":[],"_EventVenueID":[],"_OrganizerEmail":"","_OrganizerPhone":"","_OrganizerWebsite":"","_VenueAddress":"","_VenueCity":"","_VenueCountry":"","_VenueProvince":"","_VenueState":"","_VenueZip":"","_VenuePhone":"","_VenueURL":"","_VenueStateProvince":"","_VenueLat":"","_VenueLng":"","_VenueShowMap":false,"_VenueShowMapLink":false,"_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[1365],"tags":[],"class_list":["post-7766","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-example-code"],"jetpack_publicize_connections":[],"taxonomy_info":{"category":[{"value":1365,"label":"Example Code"}]},"featured_image_src_large":["https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/step-example-119-02.jpeg?fit=1024%2C576&ssl=1",1024,576,true],"author_info":{"display_name":"Joseph Simpson","author_link":"https:\/\/stepinto.vision\/author\/vrhermit\/"},"comment_info":0,"category_info":[{"term_id":1365,"name":"Example Code","slug":"example-code","term_group":0,"term_taxonomy_id":11,"taxonomy":"category","description":"Code snippets and examples of using common APIs throughout visionOS development","parent":0,"count":187,"filter":"raw","cat_ID":1365,"category_count":187,"category_description":"Code snippets and examples of using common APIs throughout visionOS development","cat_name":"Example Code","category_nicename":"example-code","category_parent":0}],"tag_info":false,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/stepinto.vision\/wp-content\/uploads\/2025\/11\/step-example-119-02.jpeg?fit=3840%2C2160&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/stepinto.vision\/wp-json\/wp\/v2\/posts\/7766","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stepinto.vision\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stepinto.vision\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stepinto.vision\/wp-json\/wp\/v2\/users\/93705089"}],"replies":[{"embeddable":true,"href":"https:\/\/stepinto.vision\/wp-json\/wp\/v2\/comments?post=7766"}],"version-history":[{"count":11,"href":"https:\/\/stepinto.vision\/wp-json\/wp\/v2\/posts\/7766\/revisions"}],"predecessor-version":[{"id":7782,"href":"https:\/\/stepinto.vision\/wp-json\/wp\/v2\/posts\/7766\/revisions\/7782"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/stepinto.vision\/wp-json\/wp\/v2\/media\/7767"}],"wp:attachment":[{"href":"https:\/\/stepinto.vision\/wp-json\/wp\/v2\/media?parent=7766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stepinto.vision\/wp-json\/wp\/v2\/categories?post=7766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stepinto.vision\/wp-json\/wp\/v2\/tags?post=7766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}