Obed Eugene
Posts: 0
Joined: Wed Jul 03, 2013 5:37 pm

Facebook Login Issues on Android

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.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Facebook Login Issues on Android

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

Obed Eugene
Posts: 0
Joined: Wed Jul 03, 2013 5:37 pm

Facebook Login Issues on Android

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Facebook Login Issues on Android

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

Obed Eugene
Posts: 0
Joined: Wed Jul 03, 2013 5:37 pm

Facebook Login Issues on Android

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Facebook Login Issues on Android

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)

Obed Eugene
Posts: 0
Joined: Wed Jul 03, 2013 5:37 pm

Facebook Login Issues on Android

Thank you so much.
this worked for me :)

Obed Eugene
Posts: 0
Joined: Wed Jul 03, 2013 5:37 pm

Facebook Login Issues on Android

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

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Facebook Login Issues on Android

Hi Obed Eugene,

Is there an error in the browser's console?

Obed Eugene
Posts: 0
Joined: Wed Jul 03, 2013 5:37 pm

Facebook Login Issues on Android

No its only when testing on Android.

Return to “Issues”