如果您向 Google 传递用户的精确位置数据,Google 发布商政策会为您提供用户意见征求要求和通知。
如果该政策适用于您,以下示例会设置标题、消息和按钮文本,以告知用户数据共享情况:
Swift
func presentConsentOverlayFromViewController(_ rootViewController: UIViewController) { if (rootViewController == nil) { return; } DispatchQueue.main.async { let alert = UIAlertController(title: "TITLE", message: "MESSAGE_TEXT", preferredStyle: .alert) let alertAction = UIAlertAction(title: "BUTTON_TEXT", style: .default, handler: { _ in print("CONSENT_RECEIVED_LOG_MESSAGE") } ) alert.addAction(alertAction) rootViewController.present(alert, animated: true, completion: nil) } } // To use the previous function, and if you are in a view controller, call: presentConsentOverlayFromViewController(self)
Objective-C
- (void)presentConsentOverlayFromViewController:(UIViewController *)rootViewController { if (rootViewController == nil) { return; } dispatch_async(dispatch_get_main_queue(), ^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"TITLE" message: @"MESSAGE_TEXT" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *ok = [UIAlertAction actionWithTitle:@"BUTTON_TEXT" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [alert dismissViewControllerAnimated:YES completion:^{ NSLog(@"CONSENT_RECEIVED_LOG_MESSAGE"); }]; }]; [alert addAction:ok]; [rootViewController presentViewController:alert animated:YES completion:nil]; }); } // To use the previous function, and if you are in a view controller, call: [self presentConsentOverlayFromViewController:self];
替换以下内容:
TITLE:意见征求对话框的标题,例如Location data。MESSAGE_TEXT:同意对话框的文本,例如:We may use your location and share with third parties for the purposes of personalized advertising, analytics, and attributions. To learn more, visit our privacy policy at example.com.BUTTON_TEXT:同意对话框按钮的文本,例如OK。CONSENT_RECEIVED_LOG_MESSAGE:用户表示同意时要记录的日志消息,例如Consent received。