0
votes

In my app, on appcelerator with titanium, I try to login with facebook but callback not working, here is my code :

var FB = require('facebook');
FB.forceDialogAuth = true;
FB.initialize();
FB.permissions = [
    'public_profile',
    'user_friends',
    'user_about_me',
    'email',
    'user_birthday',
    'user_hometown',
    'user_likes',
    'user_location'
];

UserManager.loginWithFb(function(){
    checkProfile();
});

In User Manager

exports.UserManager.prototype.loginWithFb = function(callback) {
    function facebookLogin(e) {
        console.log('facebook function');
        if (e.success) {
            UserManager.getUser(function(user){
                FB.removeEventListener('login', facebookLogin);
                callback();
            });
        } 
        else if (e.error) {
            console.log(e.error);
        }
    }
    console.log('loginWithFb');
    FB.addEventListener('login', facebookLogin);
    FB.authorize();
    console.log('FB next');
};

It works perfectly on iOs but not on Android.

My tiapp.xml is like :

<manifest>
            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
            <application android:theme="@style/Theme.AppCompat.NoTitleBar">
                <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
                <activity
                    android:name="com.facebook.FacebookActivity"
                    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
                    android:label="AppName"
                    android:theme="@android:style/Theme.Translucent.NoTitleBar"
                    />
                <activity
                    android:name="com.facebook.CustomTabActivity"
                    android:exported="true">
                    <intent-filter>
                        <action android:name="android.intent.action.VIEW" />
                        <category android:name="android.intent.category.DEFAULT" />
                        <category android:name="android.intent.category.BROWSABLE" />
                        <data android:scheme="@string/fb_login_protocol_scheme" />
                    </intent-filter>
                </activity>
                <meta-data
                    android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyC-v_Vk5Y_bPlYi4s1M76KFhp81aua1EcA"/>
            </application>
        </manifest>

I have not error just console log statues : - 'loginWithFb' - 'FB next'

I don't understand, I read documentation and it's the same way to login with facebook on Android.

If anybody can help me on this problem

2

2 Answers

0
votes

Try following steps:

1- Remove this:

FB.forceDialogAuth = true;

2. re-shuffle these lines like this:

FB.permissions = [
    'public_profile',
    'user_friends',
    'user_about_me',
    'email',
    'user_birthday',
    'user_hometown',
    'user_likes',
    'user_location'
];
FB.initialize();

Initialize must be called after permission is set. Finally, before calling authorize(), you need to set proxy worker on Android like this:

3- Add window proxy to fb instance:

$.yourWindow.fbProxy = fb.createActivityWorker({lifecycleContainer: $.yourWindow});
0
votes

I tried your solution and it always the same thing.

Here is my console logs :

[WARN] :   BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 2990
[WARN] :   chromium: [WARNING:spdy_session.cc(2527)] Received WINDOW_UPDATE for invalid stream 21
[INFO] :   loginWithFb
[INFO] :   FB next
[WARN] :   AwContents: onDetachedFromWindow called when already detached. Ignoring
[WARN] :   BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 2990
[WARN] :   chromium: [WARNING:keycode_converter.cc(91)] empty code string
[WARN] :   BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 2990
[WARN] :   IInputConnectionWrapper: getSelectedText on inactive InputConnection
[WARN] :   IInputConnectionWrapper: requestCursorAnchorInfo on inactive InputConnection
[WARN] :   IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
[WARN] :   chromium: [WARNING:keycode_converter.cc(91)] empty code string
[WARN] :   BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 2990

Is it a problem if my view is created like this :

//-- SLIDE 4
    var slide_04 = Ti.UI.createView({
        width:'100%',
        height:'100%',
        backgroundColor:'#44BBA4'
    });

    var label_04 = Ti.UI.createLabel({
        text:"Slide 4",
        color:'#222',
        textAlign:'center',
        font: {
            fontSize:24
        },
        touchEnabled:false
    });
    slide_04.add(label_04);
    scrollableDemo.addView(slide_04);

    slide_04.fbProxy = FB.createActivityWorker({lifecycleContainer: slide_04});