Access to my Facebook application from phonegap - javascript

when I register my Facebook application I asked for Website URL. That means that only users from that URL can be access to Facebook API. But I don't need it.
I'm made a mobile application by phonegap, I used ionic (HTML5 mobile framework).
I made an initialize to Facebook SDK in my javascript files, and tried to access to the api. Well it didn't work becuase the hostname on mobile application is '' (none, nothing, empty string), there is no hostname/URL parameter on mobile application.
When I tried it on my computer it worked when I put in Facebook application settings this website URL: http://localhost/, and it's worked becuase i really was on localhost.
How should I fix it, so I could access to my application from every URL and not only the URL I asked in the application settings?
Sample of my javascript code: (Written with angular.js)
$scope.loginFB = function() {
Facebook.login(function(loginResponse) {
if(loginResponse.status == 'connected') {
$rootScope.$storage.local.userLoggedIn = true;
Facebook.api('/me', function(facebookUser) {
$rootScope.$storage.local.currentUser = facebookUser;
});
}
});
};

take a look to sociogram sample on github
, a sample application demonstrating how to integrate with Facebook in your Angular/Ionic apps

If you have a mobile application, you should integrate with facebook mobile sdk for android and ios.
See:
https://developers.facebook.com/docs/ios/
https://developers.facebook.com/docs/android
There are several cordova plugins that can help you with such integration (I am the author of one by the way). You can search for these plugins at http://plugreg.com/search?q=facebook

I have successfully used Facebook connect plugin and for ionic framework you can also try ngCordova Facebook

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,
})

How to open an external app in Cordova/Ionic?

I'm working on an ionic app. In my app I want to have a button that will open another app. I tested the hyper link in safari and the link opens the app correctly, but when I click the button inside my Ionic app, it's not working. The Xcode reports
Failed to load webpage with error: The URL can’t be shown
Any suggestions?
If you are trying to use externally hosted web application in your cordova application, check out cordova-hosted-webapp-plugin. The plugin enables using content hosted in a web site inside a Cordova application by providing a manifest that describes the site. Also it lets you use the features of Cordova plugins too.
But if you are trying to just invoke the external web URL from your cordova app, you can make use of cordova-InAppBrowser-Plugin which opens the web URL inside the app itself.
You can also check out cordova-themeable-browser-plugin which is almost similar to InApp browser plugin and provides more control on the browser elements available in the UI. Hope it helps

Android application with phonegap using html5 javascript

I'm building android application with the help of phonegap (I'm using html5 and javascript).
The two questions I have are as follows:
I'm not able to complete instagram integration step 3 to access token from url. Can anyone help as I want to use javascript code for the actions above?
My application has feature to upload pictures but that should be done using instagram application. So how to invoke or redirect to already existing instagram application on clicking the camera image?
Do reply soon!

detect Android app is installed or not in device using javascript or jquery

I build a webapp and I have social links in my webapp.
I am facing an issue regarding this. If I am having facebook installed in my device then on click of the share link it should open the native app instead of opening in browser.
And incase if I doesnt have any native app installed then it should automatically redirect to browser.
Here it is the code what I have tried:
Javascript:
if(isAndroid){
fb://profile//www.facebook.com/sharer/sharer.php // to open in native browser
http://wwww.facebook.com // to open in web browser.
}
How do I handle this urls...
Please help me out.
This is not possible, for privacy reasons.
See This answer
You can make Hybrid Application.
What you just need to do is ADD WEB INTERFACE which will make call to native source code through javascript and also get return value.
So you can write native function which will return if application is installed. Once you set this interface you can use it further for open that app and passing intent and all that.
You can do it easily. Start Here:
https://developer.android.com/guide/webapps/webview.html

sencha android native app and facebook sdk

I have a problem with my sencha app, it uses facebook sdk javascript to log in, of course in the browser it works perfectly because facebook authorizes the domain name. but when i turn my app into a native android app, facebook rejects the app saying the given url is not allowed.
I have tried authorizing it as a native android app getting the key hash from the keystore I used, and putting in the facebook app with no success maybe i am missing something i would greatly appreciate any help in pointing me in the right direction
I solved it using the facebook connect plugin for phonegap and phonegap created by dave johnson
its in git hub
https://github.com/davejohnson/phonegap-plugin-facebook-connect/
You need to use the FB JavaScript library, not connect... Your best bet is to look at Jog With Friends in the ST2 examples directory to see how integration is handled

Categories