SFSafariApplication.dispatchMessage

Documentation: https://developer.apple.com/documentation/safariservices/sfsafariapplication/2823941-dispatchmessage


I'm wondering if anyone can shed some light on the following things:

  1. There does not appear to be an API to send a message from the app extension to the container app. Could someone explain the rationale for not providing that, or correct me if I'm wrong?
  2. What is the security of SFSafariApplication.dispatchMessage? Can other processes intercept these messages? Should this be considered a completely trusted channel?

Replies

There does not appear to be an API to send a message from the app extension to the container app. Could someone explain the rationale for not providing that, or correct me if I'm wrong?


The issue is that the lifecycles of your Safari App Extension and your container app are very different. There is no guarantee that your container app is running when your Safari App Extension is. See https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionOverview.html#//apple_ref/doc/uid/TP40014214-CH2-SW2 and https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW1 for discussion about the lifecycles of the various processes and some other ways you can share data. Would you mind telling me why you want to send a message from your app extension to the container app?


What is the security of SFSafariApplication.dispatchMessage? Can other processes intercept these messages? Should this be considered a completely trusted channel?


No other processes or extensions can intercept these messages.