Nếu bạn chuyển dữ liệu vị trí chính xác của người dùng đến Google, thì Các chính sách dành cho nhà xuất bản của Google sẽ cung cấp cho bạn các yêu cầu về sự đồng ý và thông báo.
Nếu chính sách này áp dụng cho bạn, thì ví dụ sau đây sẽ đặt tiêu đề, thông báo và văn bản nút để thông báo cho người dùng về việc chia sẻ dữ liệu:
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];
Thay thế nội dung sau:
TITLE: tiêu đề của hộp thoại đồng ý, ví dụ:Location data.MESSAGE_TEXT: văn bản của hộp thoại đồng ý, ví dụ: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: văn bản của nút hộp thoại đồng ý, ví dụ:OK.CONSENT_RECEIVED_LOG_MESSAGE: thông điệp nhật ký cần ghi lại khi người dùng đồng ý, ví dụ:Consent received.