I am trying to add facebook app events, and I installed FacebookSDK. Then I have next code:
import FacebookCore
static func logViewContentEvent(contentType : String, contentData : String, contentId : String, currency : String, price : Double) {
let params : AppEvent.ParametersDictionary = [
.contentType : contentType,
.content : contentData,
.contentId : contentId,
.currency : currency
]
let event = AppEvent(name: .viewedContent, parameters: params, valueToSum: price)
AppEventsLogger.log(event)
}
But I get error from the title. What I am doing wrong, and why this type is missing?
You can also share your in-app event with our worldwide team of editors for promotional consideration on the App Store. We highlight new apps and games, as well as those with significant updates, in-app events or exclusives, cultural or seasonal moments, and more.
Events (iOS) Events in iOS represent fingers touching views of an application or the user shaking the device. One or more fingers touch down on one or more views, perhaps move around, and then lift from the view or views.
In search results. When users search for an app, the event card appears along with your app for users who have downloaded your app, while screenshots show for those who haven’t downloaded your app. Users can also search for in-app events directly. When users search for an event, the event card appears along with your app.
The SDK lets you log user actions happening in the context of your app. These are commonly referred to as in-app events. The logEvent method lets you log in-app events and send them to AppsFlyer for processing. AppsFlyerLib exposes logEvent, predefined event name constants and predefined event parameter constants.
It's a knowed facebook annoying issue.
Before FBSDK 5.0.1 your code works well. After, you can change your code with for example:
static func logViewContentEvent(contentType : String, contentData : String, contentId : String, currency : String, price : Double) {
let params = [
"contentType": contentType,
"content" : contentData,
"contentID" : contentId,
"currency" : currency
]
AppEvents.logEvent(AppEvents.Name(rawValue: "viewedContent"), valueToSum: price, parameters: params)
}
In top of file get rid of FacebookCore use only
import FBSDKCoreKit
// implemented FBSDKCoreKit (5.8.0)
let event = "custom event"
AppEvents.logEvent(AppEvents.Name.init(rawValue: event))
or with parameters
let a:[String: String] = ["key": "value"]
AppEvents.logEvent(AppEvents.Name.init(rawValue: event), parameters: a )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With