Internet Connection Failure iOS Mobile Web JS SDK

We already have Facebook working on our main desktop application without any problems. When I added the same installation code to our mobile site, I received an error from the JavaScript SDK:

Received message of type object from https://s-static.ak.facebook.com, expected a string

Then I changed the installation code to the exact replica from here: https://developers.facebook.com/docs/guides/mobile/web/ and received the same message.

This error only shows when the user agent is iOS or Android in Chrome Developer Tools or in iOS Simulator. When it works from the desktop, we do not see this error.

Any idea what is going on here?

Thanks:)

+2
source share
2 answers

I had the same error. This is not necessarily the reason you get it, but I ended up looking at the packages received by my iphone simulator, and here is the error from s-statick.ak:

 [truncated] <span>Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App&#039;s settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one o 

For me, the error is that on my device (s) I browse the site through the ip address (192.168.xx, etc.), and with local development, I have hosts routing localhost to the URL that is located in my facebook app config ... so the IP address is not configured for the application.

Facebook won't let me use an IP address, so it seems like the only option is a test deployment or a DNS server. Hope this helps you.

+2
source

With all due respect, I believe that the Bokon answer does not make sense. The immediate cause of the message you receive is most likely the javascript postMessage method. It is used to link your site with the object returned by window.open or the embedded iframe website.

 window.parent.postMessage(message, targetOrigin); 

You can look at this article to find out how it works.

According to the MDN link, the first argument to the postMessage method can be of any type. However, prior to Gecko 6.0 (Firefox 6.0 / Thunderbird 6.0 / SeaMonkey 2.3), the message parameter must be a string .

I tested the method in Chrome 28.0.1500.72 (the latest version when writing this answer), and it works great when transferring an object, but still gives a warning message to the console. I think facebook feels uncomfortable with passing some rich data as a string, so they pass it as an object and just don't care about this warning. Or, since there is a workaround (e.g. JSON.stringify ), they have an error that they are not aware of.

+5
source

Source: https://habr.com/ru/post/921410/


All Articles