Google 发布商合作规范最近有更新,针对出于广告相关目的而向 Google 传送用户精确位置数据的发布商,在通知和用户意见征求方面提出了新的要求。
如果该政策适用于您,以下代码段演示了您向用户告知此类数据共享的一种方式:
Swift
funcpresentConsentOverlayFromViewController(_rootViewController:UIViewController){if(rootViewController==nil){return;}DispatchQueue.main.async{letalert=UIAlertController(title:"Location data",message:""" We may use your location, and share it with third parties, for the purposes of personalized advertising, analytics, and attribution. To learn more, visit our privacy policy at https://myapp.com/privacy. """,preferredStyle:.alert)letalertAction=UIAlertAction(title:"OK",style:.default,handler:{_in// TODO: replace the below log statement with code that specifies how// you want to handle the user's acknowledgement.print("Got consent.")})alert.addAction(alertAction)rootViewController.present(alert,animated:true,completion:nil)}}// To use the above function assuming you are in a view controller:presentConsentOverlayFromViewController(self)
Objective-C
-(void)presentConsentOverlayFromViewController:(UIViewController*)rootViewController{if(rootViewController==nil){return;}dispatch_async(dispatch_get_main_queue(),^{UIAlertController*alert=[UIAlertControlleralertControllerWithTitle:@"Location data"message:@"We may use your location, and share it with third parties,"@"for the purposes of personalized advertising, analytics, and attribution."@"To learn more, visit our privacy policy at https://myapp.com/privacy."preferredStyle:UIAlertControllerStyleAlert];UIAlertAction*ok=[UIAlertActionactionWithTitle:@"OK"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction*action){[alertdismissViewControllerAnimated:YEScompletion:^{// TODO: replace the below log statement with code that specifies// how you want to handle the user's acknowledgement.NSLog(@"Got consent.");}];}];[alertaddAction:ok];[rootViewControllerpresentViewController:alertanimated:YEScompletion:nil];});}// To use the previous function assuming you are in a view controller:[selfpresentConsentOverlayFromViewController:self];
[null,null,["最后更新时间 (UTC):2025-08-27。"],[[["\u003cp\u003eGoogle Publisher Policies now require publishers to obtain user consent before sharing precise location data for ads.\u003c/p\u003e\n"],["\u003cp\u003ePublishers need to clearly inform users about how their location data is being used and shared with third parties.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code snippets (Swift and Objective-C) offer examples of how to create a consent overlay for iOS apps.\u003c/p\u003e\n"],["\u003cp\u003eIt's crucial to customize the consent message to accurately reflect your data sharing practices.\u003c/p\u003e\n"]]],["Google Publisher Policies now require publishers to notify users and obtain consent before sharing precise location data for ad-related purposes. The provided code examples (Swift and Objective-C) demonstrate presenting an alert to users, informing them that their location might be used and shared for personalized advertising, analytics, and attribution. Users can acknowledge this information by selecting 'OK'. Publishers should customize the alert to match their data practices and replace the example handling with their chosen method.\n"],null,["# Precise location data policy\n\nSelect platform: [Android](/ad-manager/mobile-ads-sdk/android/privacy/precise-location \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/privacy/precise-location \"View this page for the iOS platform docs.\")\n\n\u003cbr /\u003e\n\nRecent updates to the [Google Publisher\nPolicies](//support.google.com/adsense/answer/9335564#use_of_device_and_location_data)\nhave introduced new notice and consent requirements for publishers who pass\nprecise location data of users to Google, for ads-related purposes.\n\nIf this policy applies to you, the following snippet shows one way you could\ninform your users of this data sharing: \n\n### Swift\n\n```swift\nfunc presentConsentOverlayFromViewController(_ rootViewController: UIViewController) {\n if (rootViewController == nil) {\n return;\n }\n\n DispatchQueue.main.async {\n let alert = UIAlertController(title: \"Location data\",\n message: \"\"\"\n We may use your location, and share it with third parties,\n for the purposes of personalized advertising, analytics,\n and attribution.\n To learn more, visit our privacy policy at https://myapp.com/privacy.\n \"\"\",\n preferredStyle: .alert)\n let alertAction = UIAlertAction(title: \"OK\",\n style: .default,\n handler: { _ in\n // TODO: replace the below log statement with code that specifies how\n // you want to handle the user's acknowledgement.\n print(\"Got consent.\")\n }\n )\n alert.addAction(alertAction)\n rootViewController.present(alert, animated: true, completion: nil)\n }\n}\n\n// To use the above function assuming you are in a view controller:\npresentConsentOverlayFromViewController(self)\n```\n\n### Objective-C\n\n```objective-c\n- (void)presentConsentOverlayFromViewController:(UIViewController *)rootViewController {\n if (rootViewController == nil) {\n return;\n }\n\n dispatch_async(dispatch_get_main_queue(), ^{\n UIAlertController *alert = [UIAlertController\n alertControllerWithTitle:@\"Location data\"\n message: @\"We may use your location, and share it with third parties,\"\n @\"for the purposes of personalized advertising, analytics, and attribution.\"\n @\"To learn more, visit our privacy policy at https://myapp.com/privacy.\"\n preferredStyle:UIAlertControllerStyleAlert];\n UIAlertAction *ok = [UIAlertAction\n actionWithTitle:@\"OK\"\n style:UIAlertActionStyleDefault\n handler:^(UIAlertAction *action) {\n [alert dismissViewControllerAnimated:YES completion:^{\n // TODO: replace the below log statement with code that specifies\n // how you want to handle the user's acknowledgement.\n NSLog(@\"Got consent.\");\n }];\n }];\n\n [alert addAction:ok];\n [rootViewController presentViewController:alert animated:YES completion:nil];\n });\n}\n\n// To use the previous function assuming you are in a view controller:\n[self presentConsentOverlayFromViewController:self];\n```\n| **Key Point:** This snippet is only an example. Make sure to customize the snippet to accurately reflect your data sharing practices, so users are informed of all the relevant purposes for which you share their precise location data."]]