Integrating Facebook on android and ios using JavaScript - javascript

I am using Parse for JavaScript, and is working with the ionic framework within the Intel XDK.
I am trying to incorporate social media login, where users are able to signin using facebook.
I generally know how to navigate this but my main concern is the following:
I am using facebook for javascript where it requires a URL, and when that URL is not accessible it doesn't work. Hence, on an iphone or android I cant use facebook yet.
The specific error I get is the following:
Warning
Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
What have I done as far?
I went over the following guide thoroughly:
http://www.benjamin.my/how-to-set-up-facebook-connect-plugin-and-parse-com-in-ionic-phonegap/
It does mention near the end of the guide that
You may have to add an iOS setting or Android setting too eventually when you deploy to either platform.
and this is the part where I am having issues, and for a while.
I have also looked into:
http://shatter-box.com/knowledgebase/facebook-functions-for-cordova-crosswalk-phongegap/
but I am confused in how I can grab the android hashtag. I am not using eclipse, but working within the xdk.

Related

Facebook Share Dialog deep linking from webapp

I'm succesfully using Facebook share method on my webapp like so using the FB JS SDK.
FB.ui({
method: 'share',
href: 'https://myapp.com',
})
However if a user access my webapp using mobile device it requires them to login to facebook through browser even if they have the main facebook app installed on the device. Is it possible to launch share dialog using native facebook app with intent if available and if not fallback to facebook in browser to share.
Facebook has url schemes which have worked in the past on iOS; I don't have a device to test on, but I suspect some of them likely still work.
Similar schemes exist for Android, and just like on iOS, they seem to become disabled and replaced with other tricks / techniques on occasion.
In Javascript, you can check the OS name. I would check for Android or iOS, and then attempt to trigger a url scheme for whichever you find, if either.
in addition to above answer,
chrome 61 onwards you can use share api. This will work same as android intents, with all possible user-installed-native-apps showing in tray, including facebook.
navigator.share({
title,
url,
})

Possible to use Google Play Game Services from origin file:///android_asset

Crosswalk is an excellent wrapper to allow HTML5 games to be packaged as native Android apps. You upload your HTML, JS and CSS files and it wraps it with Chromium for Android and builds an APK. It has full GPU support including WebGL, making it far better than PhoneGap.
I want to use the Google Play Game Services web API in a Crosswalk app, but it appears Crosswalk runs from the origin file:///android_asset. E.g. the main page will run from file:///android_asset/www/index.html.
It does not appear possible to allow Crosswalk apps to use the web API. The API console rejects file:///android_asset as an "invalid URI". Is there any workaround to this? Crosswalk is the only sensible way to publish HTML5 games as native apps on Android, and it's a shame if we can't use Google Play services!
The JavaScript code is limited by the same-origin policy, so you cannot access the Google play services(https://www.googleapis.com/*) from the origin file:///android_asset.
But Crosswalk has provided the solution for the cross-origin xhr, you can easily achieve that via adding the following configure to the manifest of your app.
{
...
"xwalk_hosts": [
"http://www.host-you-want-to-go.com/*"
],
...
}
More details in wiki.
You must try it in the latest beta version of Crosswalk, 6.35.131.5.
You can also ask the help about Crosswalk on the crosswalk-help#lists.crosswalk-project.org, in which you could get more faster response.
I wrote a simple example that accesses google play game services with cordova and crosswalk. See https://github.com/rscohn2/phonegapi
With cordova, you can create a browser window for the login, and give http://localhost as the redirect URI. After a successful login, it redirects to http://localhost,
which is not present. The app detects that the browser window has redirected. It reads the access code, then closes the window before the user can see the error.

Domain problems with my facebook login

I've created a HTML5 game that I run in my browser. I want to add facebook login, and copypasted stuff from the tutorial and replaced with my appId.
When I run it it states:
Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
The problem here is that I dont have a domain to run it under? My game is just running locally in chrome for now, but down the road I want to wrap it for mobile devices (android, ios, wp) using Phonegap or something
Are you running it inside your localhost?
Check this post for more information, it might help you:
Local Facebook App Development using localhost

How to tell if an app is installed on an ios device using JavaScript?

Is there a method to determine in a web page if the device has a particular app installed?
Depending on what you want to do, there is a way. Check out Launching an app with a custom url scheme.
If you want to get your mobile browsers to download/use your application, you can set it up with a custom url scheme as detailed in that post. From safari, add a link to your app's custom url. If you get an error or aren't redirected when a link is clicked or triggered (which you can check for with a setTimeout()) Then the app is not installed.
I don't know what your use case is, so that's the best I can do.
If you're just trying to promote your app only if it isn't installed, you can add a meta tag to the page:
<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL">
For more information, see Promoting Apps with Smart App Banners on Apple's developer website.
If that's not what you're trying to do, this answer may be helpful.

What type of FB app do I need to create for use with my windows 8 JS app?

I've had a search around here and either
The answer isn't here; or
The search engine on here sucks
but,
I am trying to add FB integration to my Windows 8 Metro (yeah I said it) JavaScript app. the only problem is I cant work out what type of app I need to create on Facebook. There are only 3 options, iOs, android, and Web App. If I choose Web App, it asks for a mobile web URL, and of course the app isn't on the web so I assume this will be a problem. Further to this is he fact that the code I need to include in my "mobile app" asks me to define a channelUrl (again, no URL, as its a metro app) so I am very confused.
Anyone here gotten this successfully working and provide me a hint as to which type of FB app I need to create so that I can get the ball rolling?
Choose the first option Website with Facebook Login. In Site Url, you should be able to put down whatever you want, eg your own site, blog, etc.
You will use Web authentication broker. See
http://code.msdn.microsoft.com/windowsapps/Web-Authentication-d0485122

Categories