Use Google Analytics for iOS without .plist file

According to the Google documentation (Analytics for iOS), they want you to download some automatically generated .plist file to customize your application. Unfortunately, I have several sets of reports (Debug, Release) and you need to dynamically switch depending on the assembly. Therefore, I am trying to do one of two things:

  • Is there a way to completely push through the .plist file and install all the configurations dynamically? What values ​​do you need?

-OR -

  1. Can I change the values ​​in the Google .plist file to use the variables from my User-Defined Build Settings project? I tried adding one of them with the name GOOGLE_ANALYTICS_ID and linking to it at $ {GOOGLE_ANALYTICS_ID} in the Google.plist file, but it does not replace the value as I expect.

How did you dynamically instruct the application to send to different report packages depending on whether your application is Debug or Release?

+5
source share
2 answers

You should be able to push through the .plist file and configure it like this:

#import "GAI.h" ... GAI *gai = [GAI sharedInstance]; [gai trackerWithTrackingId:@"your GA id"]; gai.trackUncaughtExceptions = YES; // optional gai.logger.logLevel = kGAILogLevelVerbose; // optional - remove for release 

Do not use the GGLContext material as it is trying to get the parameters from the -plist file.

+8
source

Run the same problem. My solution was to create separate build targets for QA and production, use pre-processor macros for specific target settings in the code and two separate plist files for things like facebook application id, package ids (you can specify which object to create a plist file using information about project settings).

The same thing with GA - 2 array files for each purpose and avoiding a name conflict (because if you change the plist name from GoogleService-Info, the application crashes) - just put your QA plist in a separate folder, it will work anyway just fine from there.

Do not interfere with targeted membership for you :)

0
source

Source: https://habr.com/ru/post/1234752/


All Articles