如果您將使用者的精確位置資料傳送給 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。