7

I'm trying to log some events in my iOS application using the Facebook Analytics SDK.

First, I logged an event and this works well:

FBSDKAppEvents.logEvent(FBSDKAppEventNameInitiatedCheckout, valueToSum: price, parameters: parameters)

Then I tried to log the next one:

FBSDKAppEvents.logEvent(FBSDKAppEventNamePurchased, valueToSum: price, parameters: parameters)

And Xcode says that there is no such identifier named FBSDKAppEventNamePurchased.

I dived into the Facebook documentation and recognized that it exists:

enter image description here

So, I really have not idea what hell is going on. Does anybody had the same issue?

Alexander Perechnev
  • 2,797
  • 3
  • 21
  • 35

1 Answers1

6

Okay, finally I found the reason of the problem and it's solution.

The FBSDKAppEventNamePurchased event constant is a private constant of Facebook SDK, so we can't use it in our code directly.

We should use:

FBSDKAppEvents.logPurchase(price, currency: currencyCode, parameters: parameters)

instead of:

FBSDKAppEvents.logEvent(FBSDKAppEventNamePurchased, valueToSum: price, parameters: parameters).

I really don't know why Facebook still have the FBSDKAppEventNamePurchased event on their documentation pages, but this way is the way to go.

Alexander Perechnev
  • 2,797
  • 3
  • 21
  • 35
  • 1
    Thanks, we've updated the documentation. Feel free to use the 'Give feedback' button on the documentation page (bottom left) or report the error via developers.facebook.com/bugs too when you see things like this – Chris Pan May 11 '16 at 16:16
  • 1
    @AlexKrzyżanowski Remember to contact a mod to try to get your bounty back. If not, it will be lost. – Coder1000 May 13 '16 at 07:18