mac上测试native message
下载chrome官方demo,文件夹放置位置随意
https://gitcode.com/gh_mirrors/ch/chrome-extensions-samples/tree/main/api-samples/nativeMessaging
记得安装python呀
安装原生应用程序
执行
sudo host/install_host.sh
cd ~/.Applications
,可以查看到应用程序native-messaging-example-host
加载插件
-
[更多工具] --> [扩展程序] --> [开发者模式] --> [加载已解压的扩展程序] --> [选择nativeMessaging\extension路径]
-
打开chrome-extension://knldjmfmopnpolahpmmgbagdohdnhkik/main.html,点击
connect
按钮
可能会出现下面的报错信息:Failed to connect: Failed to start native messaging host.
,这种一般就是没有权限执行脚本,执行下面命令:
sudo chmoda+x ~/.Applications/native-messaging-example-host
继续点击connect
,还有可能会出现Failed to connect: Native host has exited.
,大概率可能是python的问题,因为我就是~~
这里的python的解释器是/usr/bin/python3,可以通过 which python3
查看位置,我的是/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
,所以这里的/usr/bin/python3要替换成这个。