Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding App Events in iOS app produces undeclared identifier 'AppEvent'

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?

like image 491
Whirlwind Avatar asked Nov 27 '19 16:11

Whirlwind


People also ask

How do I promote my in-app event on the App Store?

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.

What are event events in iOS?

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.

How do I search for in-app events?

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.

What is logevent in SDK?

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.


2 Answers

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)
    }
like image 171
Alessandro Ornano Avatar answered Oct 21 '22 19:10

Alessandro Ornano


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 )
like image 27
ares777 Avatar answered Oct 21 '22 18:10

ares777