Page 1 of 4

Not worknig redirect on iOS in childbrowser.

Posted: Tue Apr 23, 2013 9:39 am
by Ricki Ricardo

I use oAuth authorization. For this I use childbrowser. When I entered login and password, them opens page with access confirmation. When I press allow application show only loading. In android all work goods.
It's trouble only in iphone, iOS 6.1.3. I have no idea with this trouble.
Could you help me? May be it's iphone bug?


Not worknig redirect on iOS in childbrowser.

Posted: Tue Apr 23, 2013 12:02 pm
by Maryna Brodina

Hello! Sorry for delay, working on it.


Not worknig redirect on iOS in childbrowser.

Posted: Tue Apr 23, 2013 2:49 pm
by Kateryna Grynko

Hi Ricki,

Did you try testing your app with oAuth in standard mobile browser without using ChildBrowser?

If you use onLocationChange event in your code then you should know the event works for Android and iPhone differently.

It dispatches on iPhone if there is a redirect to another address when open URL.


Not worknig redirect on iOS in childbrowser.

Posted: Wed Apr 24, 2013 9:33 am
by Ricki Ricardo

I open 1 address like box.com/authorize and them this site redirect to https page of my project. You mean that it will not work on ios?


Not worknig redirect on iOS in childbrowser.

Posted: Wed Apr 24, 2013 3:01 pm
by Kateryna Grynko

Hi Ricki,

I mean something else.
If there is a navigation in Child browser to page URL1 and there is a redirect to URL2, then event "onLocationChange" will be dispatched two times on Android: for URL1 and URL2. Whereas on iOS it's dispatched only once - for URL2.

If your app depends on the event this might cause the problem with iOS.


Not worknig redirect on iOS in childbrowser.

Posted: Thu May 09, 2013 1:30 am
by Christine Stringfield

Hello, I am experiencing the same problem with the iOS version of my app. We have users login to Facebook with our app following the instructions in this tutorial: http://docs.appery.io/tutorials/build...

The JavaScript opens the Facebook login window in the childbrowser, however it seems like the the FB code that is returned is getting stored in the childbrowser localstorage, so that when the childbrowser closes, all my events based on the code and retrieving a FB access token fail. Is there a way to resolve this?

Please help!


Not worknig redirect on iOS in childbrowser.

Posted: Thu May 09, 2013 2:34 am
by maxkatz

Where do you invoke the script to save the token into local storage?


Not worknig redirect on iOS in childbrowser.

Posted: Thu May 09, 2013 4:28 am
by Christine Stringfield

On the startScreen I have this code:

var redirectUrl = 'http://appery.io/app/view/fcae492f-8c...';

var url = 'https://www.facebook.com/dialog/oauth...';
url += '&redirect_uri=' + redirectUrl;
url += '&scope=email,publish_actions';
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);
};


Not worknig redirect on iOS in childbrowser.

Posted: Thu May 09, 2013 3:19 pm
by maxkatz

Looks like the code to save into local storage is invoked on this (parent) page, not in child browser.


Not worknig redirect on iOS in childbrowser.

Posted: Thu May 09, 2013 3:31 pm
by Christine Stringfield

yes it is, however when the child browser closes, none of the services will execute because there is no code to retrieve. If we keep the child browser open and never close it, we can see that the user logs in fine, but this is beyond the point. We do not want to run our entire app in the child browser because then we won't be able to use the mobile camera. The code works fine in a desktop browser, but not on iOS. Anyway you could take a look at the app so you can see what we are experiencing in the iOS simulator?