How to make Facebook App Events works on ios15?
Solution 1:
There is one important thing missed in facebook app events docs. To make facebook app events work on iOS 14+ app MUST request user for tracking. Here is example:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {[weak self] in
self?.requestTracking()
}
return true
}
func requestTracking(){
if #available(iOS 14, *) {
ATTrackingManager.requestTrackingAuthorization(completionHandler: { (status) in
switch status{
case .authorized:
Settings.shared.isAutoLogAppEventsEnabled = true
Settings.shared.isAdvertiserTrackingEnabled = true
Settings.shared.isAdvertiserIDCollectionEnabled = true
break
case .denied:
Settings.shared.isAutoLogAppEventsEnabled = false
Settings.shared.isAdvertiserTrackingEnabled = false
Settings.shared.isAdvertiserIDCollectionEnabled = false
break
default:
break
}
})
}
}
Otherwise Facebook app events will work only if app been authorised throw Facebook sign in.