i'm trying to configure Firebase Analytics with cocoapods in our app.
The app has an architecture like this:
App <- App-Framework
The app is basically just the AppDelegate importing App-Framework - which is the whole app.
Then to the problem, i'm doing this in AppDelegate:
FirebaseApp.configure()
After this i try to log an event to Analytics in the App-Framework with:
Analytics.logEvent("testEvent", parameters: [
"name": "Krister" as NSObject,
"full_text": "Krister tester" as NSObject
])
And the debugger then says:
Event not logged. Call +[FIRApp configure]: share_image
The framework and the app imports Firebase trough cocoapods and the general Firebase Analytics setup is not missing anything, like the GoogleServices.plist and imports.
I tried to implement this in an app with no framework and the events get logged to the Firebase Console and DebugView.
The weirdest thing is that the default screen tracking is getting
logged, but none of the logEvents().
What to do next?
Solution 1:
I ran the FirebaseApp.configure() inside App-Framework,
trough a method inside of AppDelegate.
Related
I implemented Adobe Lifecycle events and Firebase messaging feature in AppDelegate in two different projects.
But when I try to add adobe lifecycle code with firebase code and import the pods for Adobe Analytics (AEPCore ,AEPAnalytics ,AEPUserProfile, AEPIdentity, AEPLifecycle, AEPSignal,AEPServices ,ACPCore) then I get this error:
Cannot assign value of type 'AppDelegate' to type 'MessagingDelegate?'
Please help if someone faced this issue.
It worked when you write " extension AppDelegate: FirebaseMessaging.MessagingDelegate " instead of "extension AppDelegate: MessagingDelegate"
I’m using Xcode 12.5.1, swift 5, firebase 8.8.0
I can see the screen_view logs, user_engagement in the debugView in real time but I can’t see custom logs events.
I don’t know if I sent them correctly, can somebody help me find out please ?
I did put the GoogleService-info file with the right bundleID
I put the FirebaseApp.configure() in the didFinishLaunchingWithOptions
I did activate the -FIRAnalyticsDebugEnabled in scheme
Here is the function that I used
func logCustomEvent(name: String, category: String, action: String, label: String) {
Analytics.logEvent(name, parameters: ["eventCategory": category, "eventAction": action, "eventLabel": label])
}
Analytics.logEvent("event_log_test", parameters: ["params": "value_test"])
Thanks for your help
GoogleService-info
I resolved my problem, because i used Firebase in Pod in others frameworks that i use in my project.
So i had duplicate class firebase.
In my console log i saw :
class 'className' is implemented in both Pod
For fix it, now i just use Firebase Pod in my main project, and now i can see log event custom
In an IOS app I have
and I ensured the plist "defeat" entry is not there, and then I have analytics events like
Analytics.logEvent("touchedButton", parameters: nil)
In fact, if I run the app just in the Xcode simulator .. are these events reported to Firebase Analytics and show up?
Or perhaps if you build to an iPhone?
Or does it only work if it's an actual build which has gone through TestFlight?
Surprisingly I couldn't find this info anywhere.
Is it precisely here that such custom events will show:
Yes, both simulator or device will work.
If you haven't already read, read their getting started tutorials, it covers most of it https://firebase.google.com/docs/analytics/ios/start
A couple of points
Make sure when you configure your Firestore settings , you enable analytics
AnalyticsConfiguration.shared().setAnalyticsCollectionEnabled(true)
I do all of this initial settings in AppDelegate
something like
//init Firebase
FirebaseConfiguration.shared.setLoggerLevel(.min)
FirebaseApp.configure()
Fabric.with([Crashlytics.self])
let _ = FirebaseConfig.sharedInstance // This is a custom singelton class where I enable the analytics
In Scheme settings for your target you need to add -FIRAnalyticsDebugEnabled
As you can see I have also a disable option there, sometimes analytics goes crazy and spams the console , so I'd like to disable it with . -FIRDebugDisabled
Analytics clusters your events unless you specify it is a custom event.
For example I use following to tag the viewcontroller names
func logEvent(eventTitle:String , eventContent:String)
{
Analytics.logEvent(AnalyticsEventSelectContent, parameters: [
AnalyticsParameterItemID: "AppName-\(eventTitle)" as NSObject,
AnalyticsParameterItemName: eventTitle as NSObject,
AnalyticsParameterContentType: eventContent as NSObject
])
}
But int the firestore these are clustered under select_content section because I used AnalyticsEventSelectContent key when creating the log.
Under main events screen , select_content my view controlers logged with above function
4.There is a specific DebugView in the FirestoreConsole that works with a device, it updates every 60 seconds as long as settings for -FIRAnalyticsDebugEnabled is true in the scheme.
There is a significant delay in the Event Section of Firestore console, I don't know why this happens, but sometimes there is a delay up to 15 - 30 mins. Havent researched that issue yet, it really doesnt bother me.
Just follow https://firebase.google.com/docs/analytics/ios/start
To enable Analytics Debug mode on your development device, specify the following command line argument in Xcode :
-FIRDebugEnabled
It works perfectly for Simulator and device.
Note: For react-native debugging, launch app from xcode with the selected scheme and not with 'yarn ios', then it works perfectly for Simulator also
I've installed Google/SignIn cocoapod into my application (which I need to support GoogleDrive), but it depends on Google/Core which depends on FirebaseAnalytics. I don't want or need FirebaseAnalytics.
FirebaseAnalytics spams the developer console with 8 lines of output when our app starts:
2017-06-07 18:07:19.612994+0100 son[2909:877661] [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://gooX.gl/9vSsPb
2017-06-07 18:07:19.613 son[2909] <Warning> [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://gooX.gl/9vSsPb
2017-06-07 18:07:19.613896+0100 son[2909:877661] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3900000 started
2017-06-07 18:07:19.614 son[2909] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3900000 started
2017-06-07 18:07:19.614525+0100 son[2909:877661] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://gooX.gl/RfcP7r)
2017-06-07 18:07:19.614 son[2909] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://gooX.gl/RfcP7r)
2017-06-07 18:07:19.622560+0100 son[2909:877662] [Firebase/Analytics][I-ACS023013] Firebase Analytics disabled
2017-06-07 18:07:19.623 son[2909] <Notice> [Firebase/Analytics][I-ACS023013] Firebase Analytics disabled
(I had to add X to the URLs in the above output to get past stackoverflow's URL shortener blocker.)
I tried setting FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to YES in my Info.plist, that removed 2 lines, but added another 2 lines to tell me that Analytics is disabled (FFS!).
This spammed output makes it difficult for our developers to see any console output that is actually important. How can I disable it?
(Failing that, a suggestion on how to get it outputting each line only once would be really welcome.)
You can find this buried in the output:
<Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging
set the following application argument: -FIRAnalyticsDebugEnabled
Disabling is the opposite - set the argument: -noFIRAnalyticsDebugEnabled:
Additionally, you can control the default Firebase logging level with the setLoggerLevel method in FIRConfiguration. For example to disable all Firebase logging:
[[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelMin];
[FIRApp configure];
or in Swift:
FirebaseConfiguration.shared.setLoggerLevel(FirebaseLoggerLevel.min)
FirebaseApp.configure()
More details in the FIRLogger implementation here
To the best of my knowledge, these two lines:
[[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelMin];
[[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:NO];
placed very early in the app delegate's didFinishLaunchingWithOptions: will completely disable FireBase analytics, including stopping all the console output.
I've also since discovered that the Google/SignIn cocoapod is deprecated - the recommended one to use is GoogleSignIn (ie. no '/'). If you use GoogleSignIn, then this doesn't have a dependency on Firebase Analytics, so the original problem goes away. Now I have Google Drive support in my app and don't have Firebase Analytics!
Swift 4.0:
FirebaseConfiguration.shared.setLoggerLevel(.min)
FirebaseConfiguration.shared.analyticsConfiguration.setAnalyticsCollectionEnabled(false)
In Xcode 11.x (Swift 5 era):
This one can be a bit hairy, you may have to restart XCode even after applying the proper solution below.
Open Scheme: press COMMAND + SHIFT + < (the comma) to open up the Scheme which will drop down from the top of XCode as another window.
On the left select "Run Debug"
select the "Arguments" tab at the top of the window
enter the code below into the "Arguments Passed On Launch" section by pressing the little "+" button on the lower left.
(copy paste this)
-FIRDebugDisabled
This will disable Debug mode for Firebase for both Firestore, Firebase, and Fire Analytics.
If you haven't loaded Fire Analytics, then you can simply enter the following code into your AppDelegate.swift file:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
let db = Firestore.firestore()
// This below is the line of code to enter, but it won't stop Firebase Analytics from printing its mess in the consoleLog, but this works if you're not using FireBase Analytics.
FirebaseConfiguration.shared.setLoggerLevel(.min)
return true
}
NOTE/ADDITIONAL: You can open up your Google info.plist and write "NO" for enabling Firebase. To get Google's info.plist, just click on info.plist file, then at the top click on info.plist in the Navigation window, and it will open up a selector with Google's info.plist as a selectable item. See Figure 2.
Figure 1: What the drop-down looks like.
Figure 2: Google's info.plist
I have followed all the guidelines of how to set up the iOS SDK that QuickBlox provides. I added the SDK through cocoa pods, added the run script with the snippet code. example here! I came to a crossroad and got stuck in how to add the auth-key, app-id.. ect. To The app delegate?
This is how you set the values in AppDelegate for QuickBlox
First
import Quickblox
in your AppDelegate, then in didFinishLaunching add this
QBSettings.setApplicationID(yourAppId)
QBSettings.setAuthKey(yourAuthKey)
QBSettings.setAuthSecret(yourAuthSecret)
QBSettings.setAccountKey(yourAccountKey)