2014-03-14 2 views
0

Brefore 사용자 로그인이 코드 : 에러의FB.PublishInstall() 안드로이드

FB.Init(() => 
{ 
    FB.PublishInstall(); 
}); 

결과 :

:

03-14 10:55:01.241: I/Unity(6662): (Filename: ./Runtime/ExportGenerated/AndroidManaged/UnityEngineDebug.cpp Line: 54) 
03-14 10:55:01.326: I/Unity(6662): Exception: java.lang.ExceptionInInitializerError 
03-14 10:55:01.326: I/Unity(6662): at UnityEngine.AndroidJNISafe.CheckException() [0x00000] in <filename unknown>:0 
03-14 10:55:01.326: I/Unity(6662): at UnityEngine.AndroidJNISafe.CallStaticVoidMethod (IntPtr clazz, IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <filename unknown>:0 
03-14 10:55:01.326: I/Unity(6662): at UnityEngine.AndroidJavaObject._CallStatic (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0 
03-14 10:55:01.326: I/Unity(6662): at UnityEngine.AndroidJavaObject.CallStatic (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0 
03-14 10:55:01.326: I/Unity(6662): at Facebook.AndroidFacebook.CallFB (System.String method, System.String args) [0x00000] in <filename unknown>:0 
03-14 10:55:01.326: I/Unity(6662): at Facebook.AndroidFacebook.PublishInstall (System.String appId, Facebook.FacebookDelegate callback) [0x00000] in <filename unknown>:0 
03-14 10:55:01.326: I/Unity(6662): at FB.PublishInstall (Facebook.FacebookDelegate callback) [0x00000] in <filename unknown>:0 
03-14 10:55:01.326: I/Unity(6662): at PublishInstallController.<PublishInstall>m__87() [0x00000] in <filename unknown>:0 
03-14 10:55:01.326: I/Unity(6662): at Facebook.AndroidFacebook.OnInitComplete 

사용자가이 코드를 실행하기 이전에 로그인되어 있으면

모든 것이 잘됩니다.

documentation는 (2 단계 : 페이스 북 SDK 추가)를 말한다 :

After installing the SDK, include the following code to be executed when your app is in the foreground. This will allow the app to ping back the install event to Facebook when the user opens up the app for the first time, and again in the future if there is a network error. Our client code will stop sending installs once it acquires a success code from the server, and our back-end will only count the install a single time if it receives multiple hits for the same device:

질문 :

  1. 난 당신이 사용자 전에 FB.PublishInstall() 를 호출 할 수있는 제대로 이해 했나 페이스 북에서의인가?
  2. 이 오류를 해결할 가능성이 있습니까?

답변

1

[편집] :

저와 동료는 적어도 우리의 경우에 대한 해결 방법을 발견했다. 우리는 logcat 로그를 점검하고 "AsyncTask"오류를 발견했습니다. 내가 확인할 수있는 것부터, Facebook Android SDK가 다른 스레드에서 publishInstall을 호출하려고 시도하고 이것이 AsyncTask를 사용하여 앱에서 처음 호출하는 경우 충돌이 발생합니다.

이 게시물에 따르면 : http://grokbase.com/p/gg/android-developers/11ajf99wrs/possible-bug-in-asynctask 해결 방법은 "시스템을 속이는"AsyncTask를 통해 더미 작업을 실행하는 것일 수 있습니다. 이것은 우리를 위해 일했고 응용 프로그램은 더 이상 충돌하지 않습니다. 희망이 도움이됩니다.

[/ 편집] 경우

여전히 대답을 검색하는 :

Does FB.PublishInstall Require AuthToken?

  1. benp가 publishInstall는 액세스 토큰을 필요로하지 않는다는 것을 언급, 그래서 난 PublishInstall은 권한 부여 전에 호출 될 수 있다고 말한 것을 기반으로 추측합니다.

  2. 동일한 문제가 있지만 특정 장치에서만 충돌이 발생합니다. 일부 장치는 충돌없이 오류 메시지 만 인쇄합니다. Facebook SDK 버그 일 수 있습니다.

0

이 문제의 해결책을 찾은 것 같지만이 목적을 위해 페이스 북 SDK 플러그인의 소스 코드를 변경해야했습니다. FB.java (com.facebook.unity.FB) 파일에서 :

@UnityCallable 
    public static void PublishInstall(String params_str) 
    { 
     final UnityMessage unityMessage = new UnityMessage("OnPublishInstallComplete"); 
     final UnityParams unity_params = UnityParams.parse(params_str); 
     if (unity_params.hasString("callback_id")) { 
      unityMessage.put("callback_id", unity_params.getString("callback_id")); 
     } 
     if (Looper.myLooper() == null) 
     { 
      Looper.prepare(); 
     } 
     AppEventsLogger.activateApp(getUnityActivity().getApplicationContext()); 
     unityMessage.send(); 

    }