4
AngularJS를 사용하여 Chrome 패키지 앱을 만들고 있는데 백그라운드 스크립트 ('runtime.js')에서 다른 앱으로 메시지를 보내려고합니다. 내 프로젝트의 자바 스크립트 파일.Chrome 패키지 앱 - background.js에서 다른 스크립트 페이지로 전달되는 메시지
manifest.json을
{
"name": "App Name",
"description": "Chrome Packaged",
"version": "0.0.9",
"manifest_version": 2,
"icons": {
"16": "img/icon16.png",
"48": "img/icon48.png",
"128":"img/icon128.png"
},
"app": {
"background": {
"scripts": ["runtime.js"]
}
},
"permissions": [
"alarms",
"storage",
"unlimitedStorage",
"notifications",
"app.runtime"
]
}
runtime.js
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
minWidth: 400,
minHeight: 700,
bounds: {
width: 1000,
height: 700
}
});
});
chrome.runtime.sendMessage({message: "hello"}, function() {
console.log('sent')
});
main.js
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
console.log('message received!');
});
나는 배경 페이지 "포트입니다 검사 할 때 점점 계속 오류 : 수 수신 연결이 존재하지 않습니다. "
어떤 문제 일 수 있습니까? 감사!
주된 문제는 백그라운드 프로세스가 비 백그라운드 스크립트와 통신하도록하려는 것입니다. – adam8810