Search code examples
swiftfacebookfacebook-sdk-4.0apptrackingtransparencyin-app-events

Request Tracking Authorization for iOS Application Facebook App Events


I am trying to integrate app events for my iOS application. Below are the steps I have taken:

  • Configured Facebook App and added iOS platform
  • Linked ad account
  • Set up dev environment and SDK
  • Configured my project plist
  • Connected app delegate
  • Added manual logs

No log was getting recorded. After some research I found out that in iOS 14+ isAutoLogAppEventsEnabled, isAdvertiserTrackingEnabled and isAdvertiserIDCollectionEnabled have to be enabled.It is also done.

Any help is really appreciated on this.


Solution

  • Facebook documentation on app events is very vague. It does not contain any information about ATTrackingManager which is necessary to track events. Below are the steps I have taken to successfully connect app events (iOS 15):

    1. All steps in the documentation.

    2. Info.plist

      enter image description here

    3. SceneDelegate:

      enter image description here

      func sceneDidBecomeActive(_ scene: UIScene) {
               print("sceneDidBecomeActive")
      
               DispatchQueue.main.asyncAfter(deadline: .now() + 1) {[weak self] in
                           self?.requestTracking()
               }     
         } 
      

    enter image description here

    This will bring up the following tracking pop up at app launch:

    enter image description here

    1. In your viewcontroller:

    enter image description here