Hi,
I have native service app and a web app. In that I’m trying to send telephone call status from native service app to web app using “Event Broadcast & Subscription” (https://docs.tizen.org/application/native/guides/app-management/event/).
- Native code for broadcasting event:
bool SendEvent(bundle *msg) {
if (!msg) return false;
int ret = event_publish_app_event(“event.com.test.service.call_status_event”, msg);
if (ret == EVENT_ERROR_NONE) {
LOG_INFO(“Event sent successfully”);
} else {
LOG_ERROR(“Failed to send event: %d”, ret);
}
bundle_free(msg);
return (ret == EVENT_ERROR_NONE);
}
I have tested this code with another native application and it’s working fine.
- To receive event on web app I’m using “addEventListener”. (https://developer.tizen.org/community/tip-tech/tizen-web-broadcasting-and-listening-custom-events)
Web App event listener code:
var listener;
var app = tizen.application.getCurrentApplication();
function onEvent(event, data) {
console.log(“Received data:” + JSON.stringify(data));
}
function listenToEvent(){
var appEvent = { appId: “com.test.service”, name: ‘call_status_event’ };
try {
listener = app.addEventListener(appEvent, onEvent);
} catch (e) {
console.error(e.message);
}
}
In this code, no matter what I pass as appId, it always throws “Invalid appId” error.
How do we fix it?