Google 게시자 정책의 최근 업데이트에서는 광고 관련 목적으로 사용자의 정확한 위치 데이터를 Google에 전달하는 게시자를 대상으로 새로운 알림 및 동의 요건을 도입했습니다.
이 정책의 적용을 받을 경우, 다음 스니펫에 이러한 데이터 공유에 대해 사용자에게 알릴 수 있는 한 가지 방법이 표시됩니다.
Swift
func presentConsentOverlayFromViewController(_ rootViewController: UIViewController) { if (rootViewController == nil) { return; } DispatchQueue.main.async { let alert = 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) let alertAction = 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 = [UIAlertController alertControllerWithTitle:@"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 = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [alert dismissViewControllerAnimated:YES completion:^{ // TODO: replace the below log statement with code that specifies // how you want to handle the user's acknowledgement. NSLog(@"Got consent."); }]; }]; [alert addAction:ok]; [rootViewController presentViewController:alert animated:YES completion:nil]; }); } // To use the previous function assuming you are in a view controller: [self presentConsentOverlayFromViewController:self];