หากคุณส่งข้อมูลตำแหน่งที่แน่นอนของผู้ใช้ไปยัง 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 dataMESSAGE_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: ข้อความของปุ่มกล่องโต้ตอบความยินยอม เช่นOKCONSENT_RECEIVED_LOG_MESSAGE: ข้อความในบันทึกที่จะ บันทึกเมื่อผู้ใช้ให้ความยินยอม เช่นConsent received