I have a problem when created a new app in facebook and use it for sharing in Titanium with the Facebook Module , i get this error :
Error: HTTP status code: 403
[ERROR] : FB: The operation couldn’t be completed. (com.facebook.sdk error 5.)
So if i used my old (other) appid with the same code and and the same config in facebook apps section it works fine.
var fb = require('facebook');
fb.appid = "XXXXXXXXXXXXXXX";
fb.permissions = ['publish_stream', 'read_stream'];
if(!fb.loggedIn) {
fb.authorize();
}
var data = {
message: messageToShare,
picture: blobImageToShare
};
fb.requestWithGraphPath('me/photos', data, "POST", function(e){
if (e.success) {
Ti.API.info("FB: Success! Shared to FB: " + e.result);
}
else {
if (e.error) {
Ti.API.error('FB: '+ e.error);
}
else {
Ti.API.error("FB: Unkown result sharing");
}
}
});
Titanium version : 3.3.0
Titanium SDK 3.3.0
Platform & version : iOS >=6
Device: iOS simulator, iPhone 4 & 5.
any solution for this problem ?
You need to make sure the Facebook authorization completes before attempting to do a Graph query.
fb.authorize();
fb.addEventListener('login', function(e) {
Ti.API.debug('Returned from Facebook.');
if (e.success) {
Ti.API.debug('Authorized with Facebook, yeeey!');
// Query Graph now that we're authorized...
}
else if (e.error) {
Ti.API.debug('Error logging in with Facebook: ' + e.error);
}
else if (e.cancelled) {
Ti.API.debug('Cancelled logging in with Facebook.');
}
else {
Ti.API.debug('Something else. May actually be logged out.');
}
});
Also, make sure you define your Facebook appid in your tiapp.xml file:
<property name="ti.facebook.appid">xxxxxxxxxxxx</property>
Related
I have followed this GitHub URL to integrate Facebook sharing in my application.
https://github.com/facebook/react-native-fbsdk
Here is my code:
constructor(props){
super(props);
this.state={
shareLinkContent : {
contentType: 'link',
contentDescription: 'Facebook sharing is easy!',
contentUrl: 'https://cabbazar.com',
},
}
shareLinkWithShareDialog() {
var tmp = this;
ShareDialog.canShow(tmp.state.shareLinkContent).then(
function(canShow) {
if (canShow) {
return ShareDialog.show(tmp.state.shareLinkContent);
}
}
).then(
function(result) {
console.log('handle result: ' + result);
},
function(error) {
console.log('Share fail with error: ' + error);
}
);
}
But I am always getting an error in my simulator. Do I need to setup anything in for Xcode?
I checked this url but it is not solving my problem.
null is not an object (evaluating 'ShareDialog.canShow')
Please suggest.
Thanks
Sometimes auto link doesn't work. So you have to link manually using react-native link react-native-fbsdk
I am trying to use react-native-fbsdk in my react-native app. It was working fine untill yesterday. But, today it gives a weird error stating RCTJSONStringify() encountered the following error: Invalid type in JSON write (NSURL).
RN v0.42.0
Here is my code:
_fbAuth(error, result) {
if (error) {
console.log("error");
alert("login has error: " + result.error);
} else if (result.isCancelled) {
console.log("login cancelled");
alert("login is cancelled.");
} else {
AccessToken.getCurrentAccessToken().then((data) => {
console.log("login success");
console.log(data.accessToken.toString());
let accessToken = data.accessToken;
alert(data.accessToken.toString());
const responseInfoCallback = (error, result) => {
if (error) {
console.log(error);
} else {
console.log(result);
}
}
const infoRequest = new GraphRequest(
'/me',
{
accessToken: accessToken,
parameters: {
fields: {
string: 'email,name,first_name,middle_name,last_name'
}
}
},
responseInfoCallback
);
// Start the graph request.
new GraphRequestManager().addRequest(infoRequest).start();
});
}
}
render() {
console.log("in new render");
return (
<View style={styles.container}>
<LoginButton
publishPermissions={["publish_actions"]}
onLoginFinished={this._fbAuth}
onLogoutFinished={() => alert("logout.")}/>
</View>
);
}
The error information printed in debugger:
I get the above error while calling the graphAPI in the function responseInfoCallback. Any ideas what is happening ?
Update 1:
This error happens only when remote debugger is turned on!! Else it is not happening. But without remote debugger, I cannot proceed with developing the app. Are there any other methods to see log statements of react-native app other than remote debugger ?
Update 2:
The RCTJSONStringify() error happens only behind proxy. And also https fetch calls does not work under proxy. I tested in an open network, it works fine. I guess, it is to add some proxy information to RN app. I think it is related to APP transport security
If you turn the debugger off, you can see the proper error in the XCode console. Access it from Xcode menu View/Debug Area/Activate console, if it's not enabled automatically.
I am developing an App in Ionic/Cordova with Login over Facebook. Before showing the "Login-Page" I would like to check if the user is already connected.
The following getLoginStatus check works as expected in the iOS Simulator. When testing on the actual device, the getLoginStatus callback does not get fired.
facebookConnectPlugin.getLoginStatus(
function (response) {
if (response.status == "connected") {
set_tokens(response);
$location.path('/tab/person/me/events');
}
},
function (response) { alert(JSON.stringify(response)) }
);
Already set the Facebook-App to public and verified the App-Id.
Can anybody give a reason for the described behaviour?
I have the following implementation for Facebook login using facebookConnect Plugin.
facebookConnectPlugin.getLoginStatus(
function(response){
if(response.status == "connected"){
//do something, for example share or redirect
}else{
facebookConnectPlugin.login(["basic_info"],
function(success) { /*do something...*/},
function(error) {
//handle error
});
}
}, function(error) {
// handle error
})
}
If you still have errors, try to log the error and success events to see what is happening. This implementations works in a controller.
I developing application in Titanium Appcelerator. I had share image to twitter using the social.js link..It was worked great till yesterday. and i dont know is there anything updated in api , my share is not working and my error states "Can't get Access token" .
MyCode:
var social = require('/ui/common/social_plus');
var twitter = social.create({
consumerSecret : '1bXxxxxxxxxxxxxxxxxT0raQbg2Bhx',
consumerKey : '3xxxxxxxxxxxxxxxffFx'
});
twitter.authorize(function() {
twitter.shareImage({
message : 'Share Via ',
image : pic_loc,
success : function() {
alert('tweeted Succesfully!');
},
error : function() {
alert("ERROR Tweeted!");
}
});
});
When i run fb.login() in an ios 6 device using the account setted in Settings/facebook i get the following
operation couldn't be completed (com.facebook.sdk error 2)
in ios 5 the app works perfectly, the problem is the native login
help please ! this is my code
this is the facebook init
this.appId = appId;
var me = this;
document.addEventListener('deviceready', function() {
try {
FB.init({ appId: "294003447379425", status: true, cookie: true, nativeInterface: CDV.FB, useCachedDialogs: false });
} catch (e) {
console.log(e);
}
}, false);
if (!this.appId) {
Ext.Logger.error('No Facebook Application ID set.');
return;
}
var me = this;
me.hasCheckedStatus = false;
FB.Event.subscribe('auth.logout', function() {
// This event can be fired as soon as the page loads which may cause undesired behaviour, so we wait
// until after we've specifically checked the login status.
if (me.hasCheckedStatus) {
me.fireEvent('logout');
}
});
// Get the user login status from Facebook.
FB.getLoginStatus(function(response) {
me.fireEvent('loginStatus');
clearTimeout(me.fbLoginTimeout);
me.hasCheckedStatus = true;
if (response.status == 'connected') {
me.fireEvent('connected');
Ext.Viewport.add(Ext.create('CinePass.view.Main'));
} else {
me.fireEvent('unauthorized');
console.log('noconectado');
Ext.Viewport.add(Ext.create('CinePass.view.LoggedOut'));
}
});
// We set a timeout in case there is no response from the Facebook `init` method. This often happens if the
// Facebook application is incorrectly configured (for example if the browser URL does not match the one
// configured on the Facebook app.)
me.fbLoginTimeout = setTimeout(function() {
me.fireEvent('loginStatus');
me.fireEvent('exception', {
type: 'timeout',
msg: 'The request to Facebook timed out.'
});
Ext.Msg.alert('CinePass', 'Existe un problema con Facebook, se iniciará la aplicación sin conexión a Facebook.', Ext.emptyFn);
Ext.Viewport.add(Ext.create('CinePass.view.Main'));
}, me.fbTimeout);
this is the login
FB.login(
function(response) {
if (response.session) {
alert(response.session);
} else {
alert(response.session);
}
},
{ scope: "email,user_about_me,user_activities,user_birthday,user_hometown,user_interests,user_likes,user_location,friends_interests" }
);
Having the same problem and took me few days to figure this out, there are a number of reasons:
1) The first time you launch your app, if you deny the "Do you allow this app to use your facebook permission", you'll get this error, what you need to do is, go to Setting > General > Facebook > turn on your app OR go to Setting > General > Reset > Reset Location & Privacy (this will reset and ask you the "Do you allow this app to use your facebook permission" again for all app.
2) Slow/No Internet can caused the error
3) Create your certificate again, and go to build.phonegap.com, create a new key for IOS and change the IOS key (This works for me, I have no idea how it works but it does, I notice a significant app file size increase after i use a new IOS Key)
4) If your app is in sand box mode, and your IOS current Facebook account is not an app tester you'll get the error too. I just disable the sand box mode and it works, make sure your Facebook App Setting has the correct bundle ID, if your app is still under developement, put 0 to app store ID.