3

我正在尝试为我的本机应用程序创建一个 Safari Web 扩展。我想要一个带有按钮的弹出窗口,单击该按钮将与我的本机应用程序进行通信:

    browser.runtime.sendNativeMessage({message: "Open Main App"}, function(response) {
    console.log("Received sendNativeMessage response:");
    console.log(response);
    });

但是,应用程序无法接收到 Safari Web Extension 发送的消息:

    func beginRequest(with context: NSExtensionContext) {

    its the function that handles all things
    then
    
    if msg.contains("Open Main App") == true {
      print("NEED TO OPEN")
      guard let url = URL(string: "player:Vacation?index=1") else {
         return
      }
      NSWorkspace.shared.open(url)
    }

Safari 日志显示此错误消息:

  ReferenceError: Can't find variable: browser

怎么了?

4

0 回答 0