我想使用UI进行Mobile Safari操作扩展以更改URL。
ActionViewController.swift
@IBAction func done(){
let newURL : String = "http://google.com"
let extensionItem = NSExtensionItem()
let jsDict = [ NSExtensionJavaScriptFinalizeArgumentKey : [ "newURL" : newURL ]]
extensionItem.attachments = [ NSItemProvider(item: jsDict as NSSecureCoding?, typeIdentifier: kUTTypePropertyList as? String)]
self.extensionContext!.completeRequest(returningItems: [extensionItem], completionHandler: nil)
}
Action.js
var Action = function() {};
Action.prototype = {
run: function(arguments) {
},
finalize: function(arguments) {
var newURL = arguments("newURL");
if (newURL){
location.href = newURL;
}
}
};
var ExtensionPreprocessingJS = new Action
但运行' self.extensionContext!.completeRequest(returningItems:[extensionItem],completionHandler:nil)'
控制台显示如下:
[App]如果我们在真正的预提交处理程序中,由于CA限制,我们实际上无法添加任何新的围栏
请帮帮我。