We now have SCORM lesson characteristic in our iOS cell app. We open the SCORM lesson in WKWebView with the next code:
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
if([[NSUserDefaults standardUserDefaults] objectForKey:[TMEUserDefaultKeys cdnSetCookie]]) {
WKUserContentController *userContentController = [[WKUserContentController alloc] init];
[userContentController addScriptMessageHandler:self name:@"callNativeAction"];
[userContentController addScriptMessageHandler:self name:@"callNativeActionWithArgs"];
WKUserScript *cookieScript = [[WKUserScript alloc]
initWithSource:[NSString
stringWithFormat:@"document.cookie="%@";",
[[NSUserDefaults standardUserDefaults] objectForKey:[TMEUserDefaultKeys cdnSetCookie]]]
injectionTime:WKUserScriptInjectionTimeAtDocumentStart
forMainFrameOnly:YES];
[userContentController addUserScript:cookieScript];
[configuration setUserContentController:userContentController];
}
WKPreferences *preferences = [[WKPreferences alloc] init];
preferences.javaScriptEnabled = YES;
preferences.javaScriptCanOpenWindowsAutomatically = YES;
configuration.preferences = preferences;
configuration.websiteDataStore = [WKWebsiteDataStore defaultDataStore];
configuration.allowsInlineMediaPlayback = YES;
configuration.allowsAirPlayForMediaPlayback = YES;
configuration.allowsPictureInPictureMediaPlayback = YES;
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; //WKAudiovisualMediaTypeNone;
NSArray<NSHTTPCookie *> *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];
for(NSHTTPCookie *cookie in cookies) {
[configuration.websiteDataStore.httpCookieStore setCookie:cookie completionHandler:nil];
}
self.webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:configuration];
self.webView.UIDelegate = self;
self.webView.navigationDelegate = self;
self.webView.allowsLinkPreview = YES;
self.webView.translatesAutoresizingMaskIntoConstraints = false;
self.webView.scrollView.bounces = NO;
self.webView.scrollView.showsVerticalScrollIndicator = NO;
self.webView.allowsBackForwardNavigationGestures = YES;
self.webView.contentMode = UIViewContentModeScaleAspectFit;
UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self motion:@selector(setNavigationBarWithGestureRecognizer:)];
UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self motion:@selector(setNavigationBarWithGestureRecognizer:)];
swipeUp.delegate = self;
swipeDown.delegate = self;
// Setting the swipe route.
[swipeUp setDirection:UISwipeGestureRecognizerDirectionUp];
[swipeDown setDirection:UISwipeGestureRecognizerDirectionDown];
[self.webView addGestureRecognizer:swipeUp];
[self.webView addGestureRecognizer:swipeDown];
[self.view addSubview:self.webView];
Even after we full the studying of lesson, whereas we fetch the standing of the lesson, it returns In Progress.
Thanks prematurely.