Using Google Service for iOS without using GoogleService-Info.plist

China☆狼群 提交于 2019-12-06 20:10:19

问题


I am able to use both Google SignIn and Analytics using GoogleService-Info.plist.

However, to reduce dependency, I want to move the information from the GoogleService-Info.plist into another .plist that contains my other information.

Would this be possible? If so, how can I do this?


回答1:


You can - both libraries allow you to configure them manually. You'll want to drop any references to GGLContext, and just setup the libraries directly:

[GIDSignIn sharedInstance].clientID = @"YOUR_CLIENT_ID";

and

[[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXX-Y"]; 

You can check the reference docs for Analytics and Sign In for more.




回答2:


Sure you can. Do not initialise through pList , use instead manual setup using your keys and constants maintained in separate space in your project.

[[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose];
 id newTracker = [[GAI sharedInstance] trackerWithTrackingId:GOOGLE_ANALYTICS_KEY];
[GAI sharedInstance].defaultTracker = newTracker;


来源:https://stackoverflow.com/questions/32362471/using-google-service-for-ios-without-using-googleservice-info-plist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!