Facebook: How to separate debug and prod mode events? - ios

I'm using the Facebook SDK to track ads mobile install and followed this tutorial: mobile ads install
So far, events in DashBoard / Insight are not separated for debug / prod mode.
Do I have to create 2 appIDs to separate the debug and prod events in DashBoard/Insight ?

My guess is to you use the DEBUG preprocessor macro (or create a new one if needed), to set the correct Facebook's appId for you build. You can use the method FBSettings setDefaultAppID: from Facebook SDK to reach this, without hardcode the appId in the Info.plist.
Let me write a simple example:
// 1 - Set the app id on compile time, based in macro you choosed
#if DEBUG
kFacebookAppID = #"your app id for debug";
#else
kFacebookAppID = #"your app id for production";
#endif
// After then, you can set the id in your app delegate initialization
[FBSettings setDefaultAppID:kFacebookAppID];
I hope this help you.

Related

Facebook SDK iOS - how to set Application ID dynamically from code?

I'm trying to set the Facebook's AppId from code, so I can choose to which app to connect to (between 2 apps, one of them is a test app).
Basically I'm looking for an equivalent for Android's SDK call:
FacebookSdk.setApplicationId(ACTIVE_APP_ID);
I'm aware of the deprecated iOS call:
[FBSettings setDefaultAppID:ACTIVE_APP_ID];
But can't seem to find alternative to it.
I'm using SDK ver 4.22.1. Thanks!
FacebookSDK v4.44.1 swift 5 - Set the Facebook App ID used by the SDK:
Settings.appID = "YOUR-FACEBOOK-APPLICATION-IDENTIFIER"
Settings.displayName = "YOUR-FACEBOOK-DISPLAY-NAME"
That's the way I have managed to set it programmatically and override the default settings at the info.plist file.
Maybe you can try :
[FBSDKSettings setAppID:ACTIVE_APP_ID];
(I am using version 4.29.0 of FBSDK).

Firebase analytics for iOS Today extension(widget extension)

I tried to add firebase analytics in today extension.
So I input the configuration code
if (![FIRApp defaultApp]) {
[FIRApp configure];
}
in today extension's viewDidLoad.
And in the Xcode's Product > scheme > Edit scheme > Run > Arguments tab, I added the '-FIRAnalyticsDebugEnabled' as I want to show the logged event in firebase console's DebugView page. But, Any events didn't printed in the page.
The log added into App (not today extension) is checked in the DebugView in real time. What should I do to show today extension's log in firebase DebugView in real time?
From my experience, you can't use the app argument on the extension. I could add break point in the extension but I could see that the flag didn't have any effect on the extension. Therefore, extensions cannot send data in debug mode for now.
You can do it from code by calling setLoggerLevel method on FirebaseConfiguration singleton and set the logger level.
please see Firebase analytics documentation :
https://firebase.google.com/docs/reference/ios/firebasecore/api/reference/Classes
Enable debug mode by passing the -FIRDebugEnabled argument to the
application. You can add this argument in the application’s Xcode
scheme. When debug mode is enabled via -FIRDebugEnabled, further
executions of the application will also be in debug mode. In order to
return to default mode, you must explicitly disable the debug mode
with the application argument -FIRDebugDisabled.
It is also possible to change the default logging level in code by
calling setLoggerLevel: on the FIRConfiguration interface.

Is it possible to have Fabric and AppStore builds at the same time?

I have an app for iPhone and always sending a testing builds to client. At the same time I have an App Store version of this app. Client wants to have beta and stable app version on device at the same time. Is it possible to do without creating a new app with another bundle id?
You can only have on app on your device with the same BundleID.
If you want both the appstore version and a test version you will need to create a new BundleID for this test version.
I suspect you could do this using separate IDs for the debug and built app and using multiple schemes to share the code base between them.
Check out this article that will help
http://nilsou.com/blog/2013/07/29/how-to-have-two-versions-of-the-same-app-on-your-device/
--Edit--
Just noticed you specifically don't want different bundles due to Push Notifications. We got around this by letting our back end services know which app we were using, and targeting the different services based on which app they use. You can do this by defining preprocessor macros like this: Add preprocessor macro to a target in xcode 6
... then reference them just before you call your back end service to register your device like this...
#ifdef ENTERPRISE
env = GLOBAL_PushNotificationEnvironmentEnt;
#endif
#ifdef DEBUG
// In debug mode, the environment should be set to Development
env = GLOBAL_PushNotificationEnvironmentDev;
#endif
if (notificationsOnBool) {
[service RegisterPushNotificationTarget:self
TargetType:GLOBAL_PushNotificationTargetType
TargetToken:deviceID
DeviceName:[UIDevice currentDevice].name
EnvironmentType:env];
}
... then in your back end code you do something like this (psuedo-code)
if (device.env == Fabric) {
sendNotification(fabricService);
} else {
sendNotification(prodService);
}

To use two Facebook app ids on the same app for testing

In order to test Facebook Events without modify the production data I need to use a second Facebook App Id inside of my iOS app. I want to do that automatically my Continuous Integration environment.
Release Scheme -> Will have production Facebook app id.
Debug Scheme -> Will have debug Facebook app id.
Do you use a pre-building script to modify the info.plist file? Do you know a better way to solve this problem?
The App ID in the plist is a convenient way to set it up but the Facebook SDK allows you to set it inside the app as well.
Newer SDK:
[FBSDKSettings setAppID:#"xxx"];
Older SDKs:
[FBSettings setDefaultAppID:#"xxxx"]
That should allow you to switch between app ids when needed.
I use compiler constants testing:
#if defined(DEBUG)
// Older Facebook SDK:
// [FBSettings setDefaultAppID:#"debugID"];
[FBSDKSettings setAppID:#"debugID"];
#else
// Older Facebook SDK:
// [FBSettings setDefaultAppID:#"productionID"];
[FBSDKSettings setAppID:#"productionID"];
#endif

Disable TestFlight check points for live app

I use TestFlight for crash reporting and logging check points for testing in development. But for live app, I want to use crash reporting only.
To disable check points I can use preprocessor macro.e.g.
#ifdef TESTFLIGHT
[TestFlight passCheckpoint:#"Some event occurred"];
#endif
But problem with this approach is that I need to use this condition every time I send check point to TestFlight. I have around 70 check points.
I am looking for a way where I need to configure at one or two places in project and don't need to care about adding if condition for each new check point I add to project.
Please note that I do want to use TestFlight for crash reporting so I cannot completely disable TestFlight.
In some common header:
#ifdef TESTFLIGHT
#define TF_PASSCHECKPOINT(s) [TestFlight passCheckpoint:(s)];
#else
#define TF_PASSCHECKPOINT(s)
#endif
Then just say:
- (void)someFunction {
TF_PASSCHECKPOINT(#"entered someFunction");
...
}

Resources