1 year ago
#267970
AliRehman7141
how to recod scorm Interactions in window.API.cmi in React Native
I have the SCORM file and opened it using the package react-native-webview. I need to track the progress but when I injected the javascript to set the variables the catch part executed and the alert shows me TypeError: undefined is not an object (evaluating 'window.API.cmi)
const injectTrack = () => {
const setTrackInjection = `
try {
window.API.cmi.core.student_id = "${user?.id ? user?.id : ''}";
window.API.cmi.core.student_name = "${user?.firstname ? user?.firstname : ''}";
window.API.cmi.suspend_data = '${suspend_data}';
window.API.cmi.core.total_time = '${total_time}';
window.API.cmi.core.session_time = '${session_time}';
window.API.cmi.core.score.raw = '${scoreRaw}';
window.API.cmi.core.score.max = '${scoreMax}';
window.API.cmi.core.score.min = '${scoreMin}';
window.API.cmi.core.lesson_status = '${lesson_status}';
window.API.cmi.core.exit = '${exit}';
} catch(error){
alert(error);
}
true;`;
webviewRef.current.injectJavaScript(setTrackInjection);
};
react-native
scorm
react-native-webview
0 Answers
Your Answer