0

我的钛应用程序出现问题...我在facebook和Appcelerator上查找了一些关于facebook模块的教程,更具体地说是登录/注销。我试图在今天调整这个错误,但我不能以任何方式......如果您可以下载和测试,我将提供我的项目以供下载。对象#<Facebook>没有方法'初始化'钛合金

我试图登录到Android,但应用程序必须是为iOS太...如果你能告诉我怎么了我两办或表明,真正的工作项目....

下载我的项目:http://we.tl/hqvEpb2aeG

下面我的文件:

Login.js

//Abir Fluxo de Caixa 
function openFluxoDeCaixa(){ 
    var winFluxo = Alloy.createController('fluxo').getView(); 
    winFluxo.open(); 
} 

fb.addEventListener('login', fbLogin); 

$.btnLoginFacebook.addEventListener('click',function(e){ 
    fb.authorize(); 
}); 


function fbLogin(e){ 

    fb.removeEventListener('login', fbLogin); 

    if(e.success){ 

     var fbdata = {}; 
     fbdata = JSON.parse(e.data); 

     var uFoto = 'https://graph.facebook.com/' + fbdata.id + '/picture?width=300&height=300'; 
     var uNome = fbdata.name; 

     var slipName = uNome.split(" "); 

     Ti.App.Properties.setString('logged', 'true'); 
     Ti.App.Properties.setString('foto', uFoto); 
     Ti.App.Properties.setString('nome', slipName[0]); 

     openFluxoDeCaixa(); 
    } 
} 


$.windowLogin.open(); 

Alloy.js

var fb = require('facebook'); 
fb.permissions = ['public_profile', 'read_stream']; 
fb.appid = 172237596444060; 
fb.forceDialogAuth = false; 
fb.initialize(); 

if(OS_ANDROID){ 
    $.windowLogin.fbProxy = fb.createActivityWorker({lifecycleContainer: $.windowLogin}); 
} 



Alloy.Globals.LocalFunctions = { 
    setLogin : function setLogin(uId, uNome, uPlataforma){ 

    var getLogin = Titanium.Network.createHTTPClient(); 
     getLogin.open("POST","http://www.skrow.cc/ws-qia/controller.php"); 

     var params = { 
      action: 'addLogin', 
      id: uId, 
      nome: uNome, 
      plataforma: uPlataforma 
     }; 

     getLogin.send(params); 
    } 
}; 

TiApp.xml

<?xml version="1.0" encoding="UTF-8"?> 
<ti:app xmlns:ti="http://ti.appcelerator.org"> 
    <id>br.com.queroinvestiragora</id> 
    <name>Quero Investir Agora</name> 
    <version>1.0</version> 
    <publisher>silviosampaio</publisher> 
    <url>http://www.queroinvestiragora.com.br</url> 
    <description>undefined</description> 
    <copyright>2015 by silviosampaio</copyright> 
    <icon>appicon.png</icon> 
    <fullscreen>false</fullscreen> 
    <navbar-hidden>false</navbar-hidden> 
    <analytics>true</analytics> 
    <guid>284edc0c-c599-4cae-9444-721cd3d22937</guid> 
    <property name="ti.ui.defaultunit" type="string">dp</property> 
    <ios> 
     <plist> 
      <dict> 
       <key>UISupportedInterfaceOrientations~iphone</key> 
       <array> 
        <string>UIInterfaceOrientationPortrait</string> 
       </array> 
       <key>UISupportedInterfaceOrientations~ipad</key> 
       <array> 
        <string>UIInterfaceOrientationPortrait</string> 
        <string>UIInterfaceOrientationPortraitUpsideDown</string> 
        <string>UIInterfaceOrientationLandscapeLeft</string> 
        <string>UIInterfaceOrientationLandscapeRight</string> 
       </array> 
       <key>UIRequiresPersistentWiFi</key> 
       <false/> 
       <key>UIPrerenderedIcon</key> 
       <false/> 
       <key>UIStatusBarHidden</key> 
       <false/> 
       <key>UIStatusBarStyle</key> 
       <string>UIStatusBarStyleDefault</string> 
       <key>CFBundleURLTypes</key> 
       <array> 
        <dict> 
         <key>CFBundleURLName</key> 
         <string>com.appcelerator.kitchensink</string> 
         <key>CFBundleURLSchemes</key> 
         <array> 
          <string>kitchensink</string> 
          <string>936940282991759</string> 
         </array> 
        </dict> 
       </array> 
      </dict> 
     </plist> 
    </ios> 
    <android xmlns:android="http://schemas.android.com/apk/res/android"> 
     <manifest> 
      <application android:theme="@style/Theme.NoActionBar"> 
       <activity android:label="@string/app_name" 
        android:name="com.facebook.LoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/> 
       <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/> 
      </application> 
     </manifest> 
    </android> 
    <mobileweb> 
     <precache/> 
     <splash> 
      <enabled>true</enabled> 
      <inline-css-images>true</inline-css-images> 
     </splash> 
     <theme>default</theme> 
    </mobileweb> 
    <modules> 
     <module platform="commonjs">ti.cloud</module> 
     <module platform="android" version="3.0.3">facebook</module> 
     <module platform="iphone" version="3.2.0">facebook</module> 
    </modules> 
    <deployment-targets> 
     <target device="android">true</target> 
     <target device="blackberry">false</target> 
     <target device="ipad">false</target> 
     <target device="iphone">true</target> 
     <target device="mobileweb">false</target> 
    </deployment-targets> 
    <sdk-version>3.5.1.GA</sdk-version> 
    <plugins> 
     <plugin version="1.0">ti.alloy</plugin> 
    </plugins> 
    <property name="appc-app-id" type="string">55ec85b523ec2d9730087189</property> 
    <property name="acs-authbase-url-development" type="string">https://secure-identity.cloud.appcelerator.com</property> 
    <property name="acs-base-url-development" type="string">https://api.cloud.appcelerator.com</property> 
    <property name="acs-oauth-secret-development" type="string">0VlBf7xO3Z3aWr2ISM6BXr2vxQH8OPaU</property> 
    <property name="acs-oauth-key-development" type="string">T8j8E5AOcEyUGOPtSZWaA4ygJLpi0pYL</property> 
    <property name="acs-api-key-development" type="string">5p3UAhCmk7I3H9lYzip5Wb97H0h9I38V</property> 
    <property name="acs-username-development" type="string">appc_app_user_dev</property> 
    <property name="acs-password-development" type="string">fUoxkjYTGqxoE8ZTJ0</property> 
    <property name="acs-authbase-url-production" type="string">https://secure-identity.cloud.appcelerator.com</property> 
    <property name="acs-base-url-production" type="string">https://api.cloud.appcelerator.com</property> 
    <property name="acs-oauth-secret-production" type="string">2JHJ4oZ4V0Ch5Gvy3GAnEkY4stnycUYn</property> 
    <property name="acs-oauth-key-production" type="string">UTUK7lzz2Vuq54fSAErTk4NaN3kghPOJ</property> 
    <property name="acs-api-key-production" type="string">3xGYGFJQAYXBK4quHslbKCfBtgAcCgXg</property> 
    <property name="acs-username-production" type="string">appc_app_user</property> 
    <property name="acs-password-production" type="string">rDD4YG0qQxtmdXg0yM</property> 
    <property name="appc-org-id" type="string">100026191</property> 
    <property name="appc-creator-user-id" type="string">baea2ab2-d377-4f02-aa1b-6b4553ffe12d</property> 
</ti:app> 

回答

1

alloy.js当你的应用程序启动,但你里面创建变量不是从默认其他控制器访问始终执行。

你需要让你的Facebook模块在全球范围内访问访问它外面alloy.js,您可以通过更改alloy.js以下行做到这一点:

var fb = require('facebook'); 
fb.permissions = ['public_profile', 'read_stream']; 
fb.appid = 172237596444060; 
fb.forceDialogAuth = false; 
fb.initialize(); 

要:

Alloy.Globals.fb = require('facebook'); 
Alloy.Globals.fb.permissions = ['public_profile', 'read_stream']; 
Alloy.Globals.fb.appid = 172237596444060; 
Alloy.Globals.fb.forceDialogAuth = false; 

在login.js你还需要调用fb.initialize之前设置一个成功的Facebook登录的回调函数()例如:

Alloy.Globals.fb.addEventListener('login', fbLogin); 

你也尝试调用fb.initialize()或fb.authorize(之前,你必须设置你的登录/登出功能),所以你将需要移动fb.initialize()来login.js或只是删除它来自alloy.js,因为你已经调用了fb.authorize()。

+0

谢谢你的朋友!另外,我必须更新Titanium SDK。 –