Я хочу вызывать нативные методы в ZoomMtg API от моего сервисного работника, чтобы делать с ним что-то, что означает открытие совещания с масштабированием на основе действий, принятых от пользователя. Я понимаю, что не могу получить доступ к глобальному объекту масштабирования от работника сервиса и должен использовать API postMessage. Любая помощь будет высоко оценен. потому что я не знаю, как я могу это сделать.
import { APP_KEY, APP_SECRET } from './Helpers/CONSTAT';
importScripts('https://cdn.onesignal.com/sdks/OneSignalSDKWorker.js');
let fldMeetingID = null;
// Remove SDK push handler
self.removeEventListener('push', self.OneSignalWorker.onPushReceived);
// Register our own custom handler
self.addEventListener('push', (event) => {
if (event.data) {
const data = event.data.json();
const notification = self.OneSignalWorker.buildStructuredNotificationObject(data);
if (notification.data.isCanceled !== 1) {
fldMeetingID = notification.data.fldMeetingID;
const options = {
body: notification.data.fldUser,
badge: './assets/images/mipmap-hdpi/ic_launcher.png',
vibrate: [200, 100, 200, 100, 200, 100, 200],
tag: 'vibration-sample',
sound: '',
dir: 'auto',
requireInteraction: 'true',
actions: [
{
action: 'accept-action',
title: 'ACCEPT'
},
{
action: 'decline-action',
title: 'DECLINE'
}
]
};
return self.registration.showNotification('WaveLink Session Notification', options);
} else {
// DON'T SHOW ANYTHING
return new Promise(function(resolve, reject) {});
}
}
});
// With this we would detect notification clicks or action clicks like so
self.addEventListener('notificationclick', (event) => {
const clickedNotification = event.notification;
if (!event.action) {
// Was a normal notification click
console.log('Notification Click.');
return;
}
function connectToCurrentMeeting(fldMeetingID) {
const meetConfig = {
apiKey: APP_KEY,
apiSecret: APP_SECRET,
meetingNumber: fldMeetingID,
leaveUrl: 'https://zoom.us',
role: 0
};
// TODO: i watn to access ZoomMtg here
ZoomMtg.generateSignature({
meetingNumber: meetConfig.meetingNumber,
apiKey: meetConfig.apiKey,
apiSecret: meetConfig.apiSecret,
role: meetConfig.role,
success(res) {
console.log('signature', res.result);
ZoomMtg.init({
leaveUrl: 'http://www.zoom.us',
isSupportAV: true,
success() {
ZoomMtg.join(
{
meetingNumber: meetConfig.meetingNumber,
userName: meetConfig.userName,
signature: res.result,
apiKey: meetConfig.apiKey,
success() {
$('#zmmtg-root').css({'display': 'block'});
console.log('join meeting success');
},
error(res) {
console.log(res);
}
}
);
},
error(res) {
console.log(res);
}
});
}
});
}
switch (event.action) {
case 'accept-action':
const promiseChain = connectToCurrentMeeting(fldMeetingID);
event.waitUntil(promiseChain);
console.log('User ❤️️\'s accept.');
break;
case 'decline-action':
console.log('User ❤️️\'s decline.');
clickedNotification.close();
break;
default:
console.log(`Unknown action clicked: '${event.action}'`);
break;
}
});