facebook android app not set up correctly titanium - android

I have created an app through facebook developers and added an iOS platform and Android platform. iOS is now working with 3.2.2. Android however is not. My aim is to post a pre defined message onto a user's wall. My code is as follows. When I press my button fbShare(outlined below), I am getting a screen pop up with facebook at the top and a message stating:
App Not Setup: The developers of this app have not set up this app properly for facebook
I added the android platform in the apps settings page and copied the bundleID from my project. I also generated the key hash for both the location of my debug keystore and my actual production keystore. Neither have worked. My code for sharing is as follows:
var fbShare=Ti.UI.createImageView({
image:'/images/fbShare.png',
width:'36dp',
height:'36dp',
left:'5dp'
});
Navbar.add(fbShare);
fbShare.addEventListener("click", function (e){
facebookLogin();
});
var fb;
var facebookLogin = function(){
fb = require('facebook');
fb.appid = 'xxxxxxxxxx';
Ti.API.info('facebook logedin?' + fb.loggedIn);
//login if not logged in
if (!fb.loggedIn) {
fb.permissions = ['publish_stream'];
fb.forceDialogAuth = false;
fb.authorize();
fb.addEventListener('login', function(e) {
if (e.success) {
Ti.API.info("Facebook logged in - stage 1");
postToFacebook();
} else if (e.error) {
alert(e.error + " - stage 1");
} else if (e.cancelled) {
alert("Facebook login cancelled - stage 2");
}
});
}else{
postToFacebook();
}
};
var data = {
link : "www.mylink.com",
name : "my name",
message : "my message",
caption : "my caption",
picture : "myPic.jpg",
description : "My description."
};
var postToFacebook = function(){
Ti.API.info("attempting to post to facebook...please wait");
fb.requestWithGraphPath('me/feed', data,
"POST", function(e) {
if (e.success) {
alert("Shared to facebook successfully!");
fbShare.setEnabled(true);
fbShare.setImage('/images/fbShare.png');
Ti.API.info("Posted to facebook wall!");
}else{
if(e.error){
Ti.API.info("cant post to facebook " + e.error);
}else{
Ti.API.info("something else happened...");
}
alert('Something went wrong with your post but facebook could not confirm what.');
fbShare.setEnabled(true);
fbShare.setImage('/images/fbShare.png');
}
});
};
I've been stuck on this for days, Any help or guidance appreciated

I had a similar issue yesterday. My code was correct but I still get that message. I fixed it by setting "Do you want to make this app and all its live features available to the general public?" to YES under "status and review" in Facebook developer website.
if you have done it already then please make sure your key Hashes are correct. Remember you need a debug key and release key.
if you have done the above steps and sure your key hashes are correct then there
will be some other issue.
I hope this helps.

Related

device user mapping in mobile first platform 7.1 console while log in through adapterbased auhentication

I am trying to create a login module from the tutorial and will be using the login user id as target in my next step :sent_EventBased_Push_notification
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.1/authentication-security/adapter-based-authentication/adapter-based-authentication-native-android-applications/
Done no changes just downloaded those sample project from github and run then in mfp and android studio as it is.And they did work wonderfully.
But in mobilefirst console though I saw the the device got registered there is no user id against it..What I mean is I am using a nexus4 to login and login id s 'my-phn-no'.So user Id should be 'my-phn-no'.
below I am pasting my AuthAdapter-impl.js [same as eg.]
function onAuthRequired(headers, errorMessage){
errorMessage = errorMessage ? errorMessage : null;
return {
authStatus: "credentialsRequired",
errorMessage: errorMessage
};
}
function submitAuthentication(username, password){
if (username==="8907870678" && password === "password"){
var userIdentity = {
userId: username,
displayName: username,
attributes: {
foo: "bar"
}
};
//WL.Server.sendMessage("Hello", "hi,gd mg")
WL.Server.setActiveUser("AuthRealm", userIdentity);
return {
authStatus: "complete"
};
}
return onAuthRequired(null, "Invalid login credentials");
}
function getSecretData(){
return {
secretData: "12345 changed for trial"
};
}
function onLogout(){
WL.Logger.debug("Logged out");
}
Can you please point out the part I am missing/how do I implement it. Thank you in advance.
I tried the same code in SIT environment where it have the actual product installed MFP 7.1 . It worked perfectly .
I guess there is some thing going wrong in my eclipse plugin.

how to protect my app from share to another?

I am a cordova/phonegap android developer, currently I have some free app and now I have plan to publish the paid app in playstore. But only one can purchase and share it to his/her friends, so they can use without pay. How can I protect it? I refer many things in internet but I am not got any solution.
I found the following cordova plugin
https://github.com/mobilino/Phonegap-android-license-plugin . But I am getting signature random values, no one match with LICENSING & IN-APP BILLING key. Or how can I use this plugin.
AndroidLicensePlugin.check(
function(data) { alert( JSON.stringify(data));},
function(errorString) { alert("error: " + errorString);}
);
Merbin, Not sure if you found your answer but here is what I have done.
When I want to share an Android App that I am selling I go to Google Play Dev and create a promotional code list and provide one of those promo code to friends.
Here is the code I have used with that same plugin.
//---------------------------
//---------------------------
function LicCheck() {
//Running HTTP vs. Native
try {
//Default none or error
setLicKeyValue(Number(99));
AndroidLicensePlugin.check(
function (data) {
licProcessJSON(data);
},
function (errorString) {
console.log('LicCheck() ERROR ' + errorString);
setLicKeyValue(99);
}
);
}
catch (err) {
setLicKeyValue(99);
console.log('LicCheck() - Error - default set to 99 (try later) ' + err)
}
}
//---------------------------
//---------------------------
function licProcessJSON(data) {
var appLicResponseCode = Number(1); //0:owns, 1:do not own
//data = {
// responseCode: 0,
// signedData: "0|-123456798|de.mobilino....", // 6 fields of | delimitered data
// signature: "" // the BASE64 encoded signature from Google
//};
console.log('data.responseCode ' + data.responseCode);
//They own the app
if (data.responseCode === 0) {
console.log('licProcessJSON() - Onwer True');
setLicKeyValue(0);
return;
}
//They do not own the app
if (data.responseCode === 1) {
console.log('licProcessJSON() - Onwer False');
setLicKeyValue(1);
return;
}
console.log('licProcessJSON() - No Data?');
setLicKeyValue(99);
}
//---------------------------------
//---------------------------------
function setLicKeyValue(value) {
localStorage.setItem(_licIndicator, Number(value));
}

Unity Facebook SDK: post screenshot to wall not working

I am using Unity 4.5, the latest facebook sdk 6.0 and I am working on android right now but it should also work on iOS.
I am trying to take a screenshot and upload it to my wall, therefore I use the standard example scene from the facebook sdk.
Everything works fine when I use my private account as a test account, and it also works with the facebook app ID's of older projects (at least 1 year old). But with a normal account (no tester) and a new facebook app it is not working.
Do I have to do a full submission to use the "post an image to the users wall" function or am I doing something wrong?
My facebook app says "This app is public and available to all users" . So I guess it should work right?
I use this for login:
private void CallFBLogin()
{
FB.Login("email, publish_actions", LoginCallback);
}
void LoginCallback(FBResult result)
{
if (result.Error != null)
lastResponse = "Error Response:\n" + result.Error;
else if (!FB.IsLoggedIn)
{
lastResponse = "Login cancelled by Player";
}
else
{
lastResponse = "Login was successful!";
}
}
And this as screenshot method:
private IEnumerator TakeScreenshot()
{
yield return new WaitForEndOfFrame();
var width = Screen.width;
var height = Screen.height;
var tex = new Texture2D(width, height, TextureFormat.RGB24, false);
// Read screen contents into the texture
tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
tex.Apply();
byte[] screenshot = tex.EncodeToPNG();
textureTest = tex;
var wwwForm = new WWWForm();
wwwForm.AddBinaryData("image", screenshot, "InteractiveConsole.png");
wwwForm.AddField("message", "herp derp. I did a thing! Did I do this right?");
FB.API("me/photos", Facebook.HttpMethod.POST, Callback, wwwForm);
}
Hope someone has a solution.
Thank you!
As per the docs. You need to submit your app for review if you require the publish_actions permission.
Review
If your app requests this permission Facebook will have to
review how your app uses it.
When requesting this permission via App Review, please make sure your
instructions are easily reproducible by our team.

Facebook Phonegap plugin - Able to log in (it seems) but cannot get access token

I am having trouble getting the phonegap facebook plugin to work. Did the following steps:
I followed the automatic installation on https://github.com/phonegap/phonegap-facebook-plugin,
added facebook-js-jdk and cdv-plugin-fb-connect to my platforms/android/assets/www folder
replaced a line in the config.xml < feature name="FacebookConnectPlugin" > to < feature name="org.apache.cordova.facebook.Connect" > (otherwise it never worked)
On startup, I get a "Cordova Facebook Connect plugin failed on init". Along with this, when I run my (copied and pasted) login function, in the logcat, a login object is returned with all of my information (name, correct userID, email, education and so on...), it says "User cancelled login or did not fully authorize". What's strange is that my getLoginStatus function seems to work properly, but doesn't return an access token. When it runs, it says that I am connected to Facebook, but in the logcat I see "cannot read property 'userID' of undefined".
I tried what was suggested by java.lang.RuntimeException: Failure delivering result ResultInfo while logging using Facebook (Don't keep activities on) but that didn't work. Any help would be appreciated, I have been trying to get this to work for an embarrassingly long time now... My functions are below:
function testLogin(){
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
FB.logout(function(response) {
console.log('Logged out.');
});
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'email'});
}
function getLoginStatus() {
FB.getLoginStatus(function(response) {
if (response.status == 'connected') {
alert('You are connected to Fb');
var fbid = response.authResponse.userID;
var token = response.authResponse.accessToken;
//console.log(response.authResponse.userID);
//console.log(response.authResponse.accessToken);
alert(response);
} else {
alert('not connected to FB');
}
});
}
function logout() {
FB.logout(function(response) {
alert('logged out');
});
}
The namespace has changed. Instead of using:
FB.login(...
You should use:
facebookConnectPlugin.login(...
And replace FB with facebookConnectPlugin elsewhere.
Read the read me.md at https://github.com/phonegap/phonegap-facebook-plugin, it might help you to keep everything up-to-date ;)

Is there a locationChange equlivent for PhoneGap InAppBrowser like in ChildBrowser

I am trying to use Google OAuth2 for Google Drive authentication on both Android and iOS. I had a solution working on Android using ChildBrowser, but it did not work on iOS. PhoneGap Build support suggested I use InAppBrowser because ChildBrowser is depreciated.
I can get iOS and Android both to prompt my user for ID/PW then it shows "Allow Access" button all in InAppBrowser to give Googl Drive access. On Android tapping Allow Access button gives page not available error with correct code and OAuth token in the url. When using childbrowser it was this change event that allowed you to check for code 4 and get the token. InAppBrowser only has LoadStart, LoadStop and Exit events.
How can I check the Google return URL for success/failure and if success grab the token?
Thanks for any and all help!
Here's how I use InAppBrowser to do Facebook auth. Since you're just trying to grab a value out of the url, it should work the same way:
var fb = {
id: '...'
,secret: '...'
,namespace: '...'
,redirect: '...'
,display: 'touch'
,scope: ['publish_actions']
,windowRef: null
,code: null
,onLoadEvent: function(event){
var url = event.url;
console.log(url);
//once we've been redirected to this domain, fb's job is done
if (/my.domain.com/.test(url)){
if (/code=/.test(url)){
//auth done
var code = url.match(/code=([^\&]+)/)
if (code) code = code[1];
window.fb.code = code;
window.fb.windowRef.close();
}else if (/error_description=/.test(url)){
//login unsuccessful
var error = url.match(/error_description=([^\&]+)/);
if (error) error = error[1].replace(/[^A-Z0-9 ]/gi, " ");
console.error("facebook login failed: " + error);
window.fb.code = null;
window.fb.windowRef.close();
}
}
}
};
var authUrl = "https://graph.facebook.com/oauth/authorize?"
+ "client_id=" + fb.id
+ "&redirect_uri=" + encodeURI(fb.redirect)
+ "&display=" + fb.display
+ "&scope=" + fb.scope.join('%2C');
fb.windowRef = window.open(authUrl, '_blank', loginPopupOptions);
//no reason we can't use the same function twice...
fb.windowRef.addEventListener('loadstart', fb.onLoadEvent);
fb.windowRef.addEventListener('loadstop', fb.onLoadEvent);
I tried to pull only the relevant bits out of our structure so hopefully it makes sense this way...

Categories

Resources