Search code examples
facebookappceleratorappcelerator-mobile

"Cannot Open Page" Error when doing Facebook single sign on in Appcelerator Titanium


I have setup a view in my appcelerator titanium app to be nearly identical to the one in the kitchen sink demo for facebook login. I want to use single sign on for IOS:

//LoginView Component Constructor
function LoginView() {
    //create object instance, a parasitic subclass of Observable
    var self = Ti.UI.createView();
        // APP ID BELOW IS CHANGED FOR DEMO PURPOSES
    Titanium.Facebook.appid = "111111111111111";
    Titanium.Facebook.permissions = ['email', 'publish_actions'];
        // ENABLE SINGLE SIGN ON
    Titanium.Facebook.forceDialogAuth = false;

    self.add(Titanium.Facebook.createLoginButton({
        style:Ti.Facebook.BUTTON_STYLE_WIDE,
        bottom:30
    }));


    return self;
}

module.exports = LoginView;

When clicking the login button, it successfully opens the facebook login dialog in safari and I login. Then when it tries to take me back to the app, I get the error:

Cannot Open the Page Safari cannot open the page because the address is invalid

Very similar code works correctly in the kitchen sink app, and also disabling single sign on makes logging in through facebook work correctly in my app.

All I have for the settings in the facebook app is: Facebook Login - Enabled

Am I missing anything from the settings?


Solution

  • Figured it out:

    In my facebook app settings (on developers.facebook.com), I set the bundle Id to the same id as my app in Appcelerator.

    Based on the q & a:

    Copied Info.plist from build/iphone/ into the root of the application.

    Added the xml element fb111111111111111 below under app to Info.plist:

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLName</key>
            <string>com.mycompany.app</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>app</string>
                <string>fb111111111111111</string>
            </array>
        </dict>
    </array>
    

    Where 111111111111111 is changed to the id of the app