Page 1 of 2

Facebook Login Issues on Android

Posted: Tue Sep 24, 2013 5:39 pm
by Obed Eugene

When testing the app on Mobile Web, the app works fine. But when testing app on android after downloading apk, the app fails at login. Im able to login to Facebook but it just redirects to the homepage and not the next screen. The app is called Voutche and I've just added a href="mailto:supprt@appery.io" rel="nofollow"supprt@appery.io/a to the project.

Thanks.


Facebook Login Issues on Android

Posted: Tue Sep 24, 2013 8:01 pm
by Kateryna Grynko

Hi Obed,

Your app uses app page address on Appery.io site as a redirectUrl whereas you need an address of the internal page of your Android app.

Replace your redirectUrl with the following code:
codevar redirectUrl = window.location.href;
redirectUrl = redirectUrl.replace( /(#.+)$/, '' );/code


Facebook Login Issues on Android

Posted: Tue Sep 24, 2013 8:52 pm
by Obed Eugene

Okay, This still redirects me to the homescreen, but I want to redirect to the voutchescore.html page. How can I do that?


Facebook Login Issues on Android

Posted: Tue Sep 24, 2013 9:15 pm
by Kateryna Grynko

Hi Obed,

Try running the following JavaScript code on Page Show event:
codeurl = window.location.href;
var vars = parseUrlVars(url);
/* if user successfully logged in /
if (vars.code != undefined) {
localStorage.setItem('code', vars.code + '_'); / store secret code /
Appery.navigateTo('result', {reverse: false}); / Navigate to page 'result' */
}/code


Facebook Login Issues on Android

Posted: Tue Sep 24, 2013 9:43 pm
by Obed Eugene

HI Katya,

I tried running the new redirectUrl on the Homescreen page and then the Javascript code on the voutchescore page but I'm still getting errors.

Here's what I have on the homescreen button click event:

var redirectUrl = window.location.href;
redirectUrl = redirectUrl.replace( /(#.+)$/, '' );

var url = 'https://www.facebook.com/dialog/oauth...';
url += '&redirect_uri=' + redirectUrl;
url += '&scope=read_stream,user_about_me,user_birthday,user_checkins,user_hometown,user_interests,user_likes, user_location,user_photos,user_relationships,user_relationship_details,user_religion_politics,user_status, user_website,user_education_history,user_work_history, user_relationships, user_religion_politics ';
url += '&state='+OAuth.nonce(17);

var cb = null;
if(window.plugins) {
cb = window.plugins.childBrowser;
}
if (cb != null) {
/* Wen native childBrowser plugin must be used to navigate to facebook. /
cb.onLocationChange = function (url) {
if(url.indexOf(redirectUrl) === 0) {
/ if user successfully logged in /
cb.close();
var vars = parseUrlVars(url);
localStorage.setItem('code', vars.code + '_'); / store secret code /
Appery.navigateTo('result', {reverse: false}); / Navigate to page 'result' */
}
};

Code: Select all

cb.showWebPage(url); 

}
else {
localStorage.setItem('code', '');
window.open(url);
};


Facebook Login Issues on Android

Posted: Wed Sep 25, 2013 8:42 am
by Maryna Brodina

Hello!
Sorry, there is a mistake.
1) Please replace code
prevar redirectUrl = window.location.href;
redirectUrl = redirectUrl.replace( /(#.+)$/, '' );/pre with the one you have before:
prevar redirectUrl = "http://appery.io/app/view/8e139ca9-3c2f-4ba0-9f0c-8c1113de0cdf/FacebookLogin.html&quot/pre
2) It doesn't work on device because of code on button click:
preAppery.navigateTo('result', {
reverse: false
}); /* Navigate to page 'result' *//pre but you don't have result page. Please navigate to any other page, for example profile:
preAppery.navigateTo('profile', {
reverse: false
});/pre
3) to make it work in browser on page Show event add the code Katya suggested above (note that you need to navigate to existing page, not the result one)


Facebook Login Issues on Android

Posted: Wed Sep 25, 2013 4:16 pm
by Obed Eugene

Thank you so much.
this worked for me :)


Facebook Login Issues on Android

Posted: Sun Sep 29, 2013 10:28 pm
by Obed Eugene

Hi, now the Facebook Data is not being saved to local storage. How do I fix this?


Facebook Login Issues on Android

Posted: Sun Sep 29, 2013 10:37 pm
by Igor

Hi Obed Eugene,

Is there an error in the browser's console?


Facebook Login Issues on Android

Posted: Sun Sep 29, 2013 10:44 pm
by Obed Eugene

No its only when testing on Android.