Using iOS to Integrate Facebook Video into User Interface Web View

Within my application, a UIWebView is utilized to display content that is generated from WordPress (HTML code sourced from embedded Facebook content). The HTML content is loaded using the method loadHMTLString:baseURL:, with the base URL being set to the URL of the mainBundle file path due to a local CSS file. The videos causing issues have been configured to be publicly visible.

The primary issue I am encountering is that when the content includes an embedded Facebook video, it fails to display properly. Instead of the expected video appearing, there is simply a blank space in its place.

A similar problem was encountered when attempting to showcase embedded posts from Twitter or Instagram, though the nature of the problem differed slightly. In those instances, a post frame would appear without any accompanying text or image. The solution involved adding "http:" to the JavaScript file link, but this approach did not resolve the issue with Facebook videos. Additionally, attempts with WKWebView proved unsuccessful. While searching for solutions within similar contexts, no relevant results were found.

Any assistance or guidance on this matter would be greatly appreciated.

Answer №1

When setting the base URL, I use the URL to the mainBundle file path

We've discovered that HTML documents containing the Facebook Javascript SDK don't function properly within a UIWebView unless the baseURL parameter is directed to an external website.

In other words,

someUIWebView.loadHTMLString(HTMLString, baseURL: nil)

won't do the trick. However,

someUIWebView.loadHTMLString(HTMLString, baseURL: URL(string: "https://google.com/"))

WILL work, even if your content has no affiliation with google.com.

It seems like the Facebook SDK requires a valid HTTP URL and doesn't play well with nil or local/file URLs.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Setting a timeout for loading an external JavaScript file that is currently inaccessible

Using JavaScript, I am integrating content from a PHP file on a different server. Unfortunately, this external service can be unreliable at times, causing delays in loading or not loading at all. I am looking for a way in JavaScript to attempt retrieving ...

What is the best way to present progress bar numbers in Bootstrap beneath the bar?

I have successfully implemented a progress bar using Bootstrap. Now, I am looking to display numerical values below the progress bar, similar to this: https://i.sstatic.net/3QG8d.png Is there a way to achieve this without utilizing JavaScript graphing l ...

NSString File Name includes unwanted %20 instead of spacing

SOLVED (Thanks Regexident) I developed an application where the file path of a PDF is passed to a custom -(id)init initialization method. When selected from the table, it triggers the else statement for a file that does not exist: - (void) gridView:(AQGr ...

Vue 3 taps into the power of reactive queries with Apollo GraphQL

Struggling to implement a dynamic query following the guidelines at , but facing difficulties in making it work. Error: Uncaught (in promise) Error: Invalid AST Node: { query: { kind: "Document", definitions: [Array], loc: [Object] }, loadingK ...

Is there a way to display a JS alert just one time?

How can I display a message to users on LT IE8 encouraging them to upgrade their browser for a better web experience? I only want the message to appear on their first visit, not every time they refresh the page. Is there a solution for this issue? Thank ...

What is the secret behind ruler apps maintaining precision across a wide range of devices?

I am puzzled by the way iOS Ruler apps in the current market claim to be compatible with various device sizes. An example is provided below. From my research, I initially believed that determining the PPI of the device screen in real-time was not feasible ...

Deactivate the array element if it is found in any of the other arrays

I have an array called Array1, with elements ["A","B","C","D","E"]. If any element in Array1 is already present in arrays Array2, Array3, or Array4, then that particular element should be disabled. This means that I will not be able to select that option ...

Change the default values for grid column configurations in Ext JS globally

The Ext.grid.column.Column class contains the following configurations: draggable (Default: true) sortable (Default: true) menuDisabled (Default: false) Is there a way to globally change the default values of these configurations for all grid columns i ...

Tips for concatenating elements to a previous state array when using an arrow function within the setState method?

When I drag and drop images to React-Dropzone library, I want to append them to the previous file state. const [files, setFiles] = useState([]) ... const { getRootProps, getInputProps, isFocused, isDragAccept, is ...

What is the best method for selecting or deselecting all checkboxes except for one using a single checkbox in angularjs

$scope.checkAll = function() { if ($scope.selectedAll) { $scope.selectedAll = true; } else { $scope.selectedAll = false; } angular.forEach($scope.MyProducts, function(item) { item.Selected = $scope.selectedAll; }); /*});*/ } <di ...

React developer server is failing to automatically refresh the code

I've encountered an issue with react-dev-server where changes I make to the code do not reflect on the app itself even after refreshing (not hot-loading). I've tried setting up my own project as well as using Facebook's Create-react-app, whi ...

iOS: Using UITextField from main view to set text in a subview in a UITabBar/UINavigationController app

I am facing an issue with setting the text value of a UISearchDisplay programatically, triggered by the load of another view. I am wondering if I have made my problem overly complex or if I am on the right track. Here's the scenario: I have a UITabBa ...

Transform the text column into JSON format

We currently have a resource bundle/properties formatted as follows: [tag1] server1 server2 [tag2] server3 server4 [tag3] server5 server6 [No Software Installed] server7 [tag2] server8 [tag5] server9 [tag1] server10 server11 [tag3] server12 server13 serve ...

The stop button for the getUserMedia Api on the webcam is unresponsive

Currently, I am running this piece of code on my XAMPP Server localhost. <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> </head> <body> <video onclick="changeFilter(this);"width=200 height=200 id="video" contro ...

Obtaining an array of weeks for the previous two months from the current date using JavaScript

Looking to generate a list of weeks for the past two months using JavaScript. Any suggestions on how to accomplish this task would be greatly appreciated. [ { "week_start": "8/01/2016", "week_end": "8/06/2016" }, { "w ...

Guide to switching between Play and Pause using a UIBarbuttonItem

Seeking assistance with a coding issue. Despite extensive searching, I have been unable to find a solution in Swift 3 for creating a toggle Play and Pause feature using a UIBarButtonItem. The goal is to play the file when the play button is clicked and sim ...

How can I retrieve the word that comes after a specific word in discord.js

Currently, I'm attempting to create a bot similar to Dad bot, but I'm struggling with implementing the "Hi __ I'm, Dad" feature. Here's the code snippet that I've put together so far: var imWords = ["i'm", "I&a ...

The DBRoulette application is unable to detect any files

After recently downloading the Dropbox SDK (v1.3.13), I decided to give the DBRoulette app example a try. I've set up my app and secret keys, established a connection successfully. However, despite placing .jpg photos in my app's folder at Dropb ...

What is the best way to empty an input field after adding an item to an array?

In my Angular 2 example, I have created a simple functionality where users can add items to an array. When the user types something and clicks the button, the input is added to the array and displayed in a list. I am currently encountering two issues: 1 ...

Enhance the functionality of NodeJS core applications

I recently attempted to modify some custom functions in the FS module of NodeJS, which is an integral part of NodeJS' core modules. The specific file I targeted was fs.js, located in /usr/lib/nodejs. However, despite making changes to the code, I noti ...