개발 기타/IOS

ios Appsflyer와 facebook 충돌 버그

소나무꼴 2021. 4. 27. 12:33

앱스플라이어와 페이스북 충돌 버그

  ios 사파리에서 페이스북이 로그아웃 상태에서 앱에서 페이스북 로그인시 실패 현상.

 

 

github.com/AppsFlyerSDK/appsflyer-unity-plugin/blob/master/docs/iOS-Swizzling-Guide.md

 

AppsFlyerSDK/appsflyer-unity-plugin

AppsFlyer Unity Plugin. Contribute to AppsFlyerSDK/appsflyer-unity-plugin development by creating an account on GitHub.

github.com

 

 

iOS Swizzling Guide
AppsFlyer Unity Plugin uses the iOS life cycle events for the SDK to work.
The plugins uses UnityAppController for the lifecycle events to be invoked.
Sometimes other plugins (Firebase, Facebook, ect) use the same UnityAppController, which creates conflicts in the lifecycle events.
These events include didBecomeActive, didEnterBackground, didReceiveRemoteNotification, continueUserActivity and openURL.
When a conflict occurs these methods may not be invoked.
The solution provided by the AppsFlyer Unity Plugin is Swizzling.
Starting from v6.0.7 there is an option to enable swizzling automatically.
To enable swizzling, in the info.plist file, a boolean K/V called AppsFlyerShouldSwizzle should be set to 1 (true).
This will automatically enable swizzling and solve conflicts with other plugins.
This can also be accomplished on the c# side by following these steps:
Create a new c# script. (we called ours AFUpdatePlist.cs)
Place the script in a editor folder (Assets > Editor > AFUpdatePlist.cs)
The code in the script should look like this:
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;

public class MyBuildPostprocessor {
    
    [PostProcessBuildAttribute]
    public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) {
        
        if (target == BuildTarget.iOS)
        {
            string plistPath = pathToBuiltProject + "/Info.plist";
            PlistDocument plist = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));
            
            PlistElementDict rootDict = plist.root;
            rootDict.SetBoolean("AppsFlyerShouldSwizzle", true);
            
            File.WriteAllText(plistPath, plist.WriteToString());
            
            Debug.Log("Info.plist updated with AppsFlyerShouldSwizzle");
        }
        
    }
}
Validate that the code in the AppsFlyer+AppController is called on the native side.
Comment out IMPL_APP_CONTROLLER_SUBCLASS(AppsFlyerAppController) in AppsFlyerAppController.mm.

'개발 기타 > IOS' 카테고리의 다른 글

페이스북 시뮬레이터 빌드  (0) 2021.04.29
ios-sim showdevicetypes 에러  (0) 2021.04.27