Faruk NANE
Faruk NANE

Reputation: 41

Microsoft Edge Extension Development | My extension can't connect my uwp app

https://learn.microsoft.com/en-us/microsoft-edge/extensions/guides/native-messaging

The link above I have read is about how to establish a connection between uwp app and Microsoft Edge. According to that link, I created my "AppService" and "EdgeExtension" as well. I tried running my "appservice" application by using a client which connects "appservice". The class inherited from IBackgroundTask is worked. I checked whether the code worked well. I think there is no problem with my "appservice" application. The problem is that I cant establish a connection between my appservice and edge extension.

Here is my appxmanifest of my appservice

    <uap:Extension Category="windows.appService" EntryPoint="RuntimeComponent3.Service">
      <uap3:AppService Name="aaaaaaaaaaaaaaaaaa" SupportsRemoteSystems="true" />
    </uap:Extension>

    <uap3:Extension Category="windows.appExtension">
      <uap3:AppExtension Name="randomname" Id="randomname" PublicFolder="Extension" DisplayName="randomname">
        <uap3:Properties>
          <Capabilities>
            <Capability Name="websiteContent" />
            <Capability Name="websiteInfo" />
            <Capability Name="browserStorage" />
          </Capabilities>
        </uap3:Properties>
      </uap3:AppExtension>
    </uap3:Extension>
    <uap:Extension Category="windows.protocol">
      <uap:Protocol Name="msghost1" />
    </uap:Extension>
  </Extensions>

I dont know if "windows.appExtension" and "windows.protocol" are needed.

Here is the manifest.json file:

  "background": {
      "scripts": [ "content.js" ],
      "persistent": true
    },

  "permissions": [
      "*://*/*",
      "nativeMessaging",
      "activeTab"
    ],

And here is the "content.js" which actually works at background (look manifest "background" section)

  browser.browserAction.onClicked.addListener((tab) => {

      alert("test");
      browser.runtime.connectNative ("aaaaaaaaaaaaaaaaaa");
      alert("test2");
  });

When I tried to connect my appservice from another uwp app, it worked well. (appservicename : "aaaaaaaaaaaaaaaaaa" and app package name were needed), but my extension cant connect me appservice. Im strugglingwith this problem. Please help me!!. Thanks and regards...

BTW first alert("test"); works wellwhereas the second doesn't.

Upvotes: 0

Views: 592

Answers (1)

Andriy
Andriy

Reputation: 84

Do you see your Extension in the EDGE->Extensions menu item ? It appears that you have incorrectly specified the app that needs to host your extension:

<uap3:AppExtension Name="randomname" Id="randomname" PublicFolder="Extension" DisplayName="randomname">

The name parameter here should specify the name of the app that should host your extension. In case with EDGE - it should be: com.microsoft.edge.extension.

I dont know if "windows.appExtension" and "windows.protocol" are needed.

The "windows.appExtension" actually declares your app as an extension.

The "windows.protocol" allows to declare a URI name that other apps can use as a URI parameter to launch your app. At least this is how I understood all that.

Here is the link to interesting presentation about UWP app extensions: https://channel9.msdn.com/Events/Build/2016/B808

Upvotes: 2

Related Questions