1

My cn1 app incorporates loggin in with Facebook and Google+. When the doLogn() is called on Iphone, A Safari page is opened which allows the user to enter their credentials for Facebook or Google respectively. The problem I am facing is that my app has just been rejected by apple because the user is taken out of the app and into safari in order to log in with Facebook or Google and this, according to apple, provides "poor user experience". Apple recommended that I use the Safari View Controller API which allows the display of a URL and inspection of the certificate from an embedded browser in an app so that customers can verify the webpage URL and SSL certificate to confirm they are entering their sign in credentials into a legitimate page.

I notice that Codename one has a WebView component. However I'm not sure if it's possible to open the url in Webview instead of Safari when I call the doLogin(). If it is. How do I achieve this and is Web View the right component to use? Or will I need to use the Safari View Controller API, if so, how do I add this api to my cn1 project, is it even possible?

I would recommend that codenameone incorporate this into their Facebook and Google login features to prevent any future users from getting rejected by the app store.

It appears that this happens automatically on Native Iphone apps - Safari web view opening when logging to FB through iOS 9. For IOS should I try to implement a native Facebook log in then? If so. Where do I start?

final Login fb = FacebookConnect.getInstance();
    fb.setClientId("XXXXXXXXXXXXXX");
    fb.setClientSecret("XXXXXXXXXXXXX");
    fb.setRedirectURI("http://www.mibrandapp.com");
    FaceBookAccess.setPermissions(new String[]{"id", "name", "first_name", "last_name"});
    fb.setScope("id");
    fb.setCallback(new LoginCallback() {
        @Override
        public void loginFailed(String errorMessage) {
            Dialog dg = new Dialog();
            dg.setTitle("Login failed");
            dg.show();
        }

        @Override
        public void loginSuccessful() {
            ....
        }
    });
    //fb.doLogin();
    fb.nativelogin();
Community
  • 1
  • 1
Kyri33
  • 599
  • 2
  • 15

2 Answers2

1

Currently the Codename One build server uses Facebook IOS SDK 4.4, which uses the default behaviour of opening the Facebook app to authenticate - if installed - and the Safari app if it is not installed.

If you switch to the "iphone_new" build target (which will soon be standard) it uses the newer Facebook IOS SDK 4.12, which will (by default) handle the authentication inside a web view in your app.

Running some tests on this approach, I found that, on iOS 9, you need to add the following to your ios.plistInject build hint:

<key>LSApplicationQueriesSchemes</key><array><string>fbauth2</string></array>

I have just committed a change that will include this automatically so after the next server update (probably on Friday), it will just work without this build hint.

UPDATE June 14, 2016

I have just updated this in SVN so that it will use IOS SDK 4.12 by default with will resolve this issue without having to make any changes. The server will be updated Friday - after which you should be able to just send your build (with no special build hints) and it will work.

steve hannah
  • 4,586
  • 11
  • 18
0

Codename One uses native Facebook login when the Facebook app is installed and activated. You need to use the Facebook Connect API as explained in the developer guide section.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • I do use the Facebook Connect API. I edited in my code above. Still opens up in Safari and still gets rejected by apple. I even tried the nativeLogin(). Call. – Kyri33 Jun 14 '16 at 12:19
  • When the user has the Facebook app it opens the app instead. However apple still aren't happy with this. They want it all to be done in my app in a Web View component. As explained here: http://stackoverflow.com/questions/32375916/safari-web-view-opening-when-logging-to-fb-through-ios-9 – Kyri33 Jun 14 '16 at 12:25
  • Do I need to download and use the native IOS Facebook SDK. Is that possible to do in cn1? If so, how? Or am I fighting a losing battle? We're two weeks away from launch and we cannot upload the app until we fix this. If this can't be done in cn1 then we may as well render codename one's Facebook log in abilities useless as it won't be approved by the app store. I hope there is a way to fix this problem. – Kyri33 Jun 14 '16 at 13:10
  • 1
    CN1 already uses the native IOS Facebook SDK internally if you use the appropriate build hints as described in the docs. – steve hannah Jun 14 '16 at 15:30
  • @stevehannah I already have the build hint facebook.appid as well as facebook=true. The app still opens safari app to log in IF the user doesn't have the Facebook app. When the user has the facebook app then it will log in using the facebook app. However apple are rejecting me because my app opens safari to log in if the user doesn't have the Facebook app. Are there any other build hints I must include? I tried using nativeLogin and doLogin. Do I need to update cn1 or something? – Kyri33 Jun 14 '16 at 16:01
  • This is done in the server and we use the latest Facebook SDK. From the thread you linked it looks like this is the behavior Facebook chose to take so it's a problem with the native SDK. It's unclear to me what we can do in this case? – Shai Almog Jun 14 '16 at 16:31
  • @ShaiAlmog It seems as though I am going to have to log in using native IOS code in order to change the login behaviour of the IOS login manager to web instead of browser. However in my native code I will need to #import the Facebook Sdk. Specifically the FBSDKLoginKit.h and FBSDKCorekit.h . Correct me if I'm wrong but I need the directories of those files and the sdk manager to #import them in my code. Could you please assist me as to what directory to use. Or do I need to download my own sdk manager and add it to my app. – Kyri33 Jun 14 '16 at 17:29