Shinning River
Shinning River

Reputation: 813

Extension for Safari IOS 8

I am working on extension for safari.I have checked we can communicate between host app and extension as we can run extension or close extension.But in my case I want to communicate with host app without closing extension app.

var MyExtensionJavaScriptClass = function() {};
MyExtensionJavaScriptClass.prototype = {
run: function(arguments) {
    arguments.completionFunction({"baseURI": document.documentElement.innerHTML});
 },

test: function(arguments) {

    alert("Need to run without closing extension");

},
finalize: function(arguments) {

    alert("Test Done");
    // arguments contains the value the extension provides in [NSExtensionContext completeRequestReturningItems:expirationHandler:completion:].
    // In this example, the extension provides a color as a returning item.
    document.body.style.backgroundColor = arguments["bgColor"];

}
};
var ExtensionPreprocessingJS = new MyExtensionJavaScriptClass;

In above my JavaScript file I have run function that run at the time of extension run and finalize fun run as we call completeRequestReturningItems in objc side.I want to run my test function without closing extension

Upvotes: 1

Views: 1478

Answers (2)

Joseph A
Joseph A

Reputation: 11

Quick terminology level set:

Containing App = "an app that contains one or more extensions is called a containing app" Host App = "An app that can let users choose an extension to help them perform a task is called a host app."

That being said, Apple does not supply a communication stream from Host App to extension. In your case, you can load data initially with the run() in the JS Preprocessing file and then respond with data on exit of the extension with finalize().

Upvotes: 1

Charles Maria
Charles Maria

Reputation: 2195

You don't.

To quote Apple's Extension Guidelines, from the section How an Extension Communicates.

There is no direct communication between a running extension and its containing app; typically, the containing app isn’t even running while its extension is running.

This isn't to say that you cannot, just that Apple doesn't want you, and the ability to do so is probably either private or non-existent.

Upvotes: 4

Related Questions