<!--
{
  "availability" : [
    "macOS: 10.12.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SafariServices",
  "identifier" : "/documentation/SafariServices/SFSafariExtensionHandling/messageReceived(withName:from:userInfo:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Safari Services"
    ],
    "preciseIdentifier" : "c:objc(pl)SFSafariExtensionHandling(im)messageReceivedWithName:fromPage:userInfo:"
  },
  "title" : "messageReceived(withName:from:userInfo:)"
}
-->

# messageReceived(withName:from:userInfo:)

A method the system calls when the extension receives a message from an injected script.

```
optional func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String : Any]? = nil)
```

## Parameters

`messageName`

A string that identifies the message.

`page`

The page that sent the message.

`userInfo`

Optional message content. If specified, the dictionary’s value objects conform to the W3C standard for safe passing of structured data, such as Boolean objects, numeric values, strings, and arrays.

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)