ユーザーのEメールアドレスを要求するには、あなたのアプリがTwitterのホワイトリストに登録されている必要があります。 お問い合わせには、こちらのフォームを使ってください。
TWTRShareEmailViewControllerはユーザーに対して、tiwtterアカウントに登録されているメールアドレスへのアクセスを要求するビューを表示します。
これは個人情報を扱う上で必ず表示しなければなりません。
Request a User's Email AddressRequesting a user’s email address requires your application to be whitelisted by Twitter. To request access, please use this form. The
|
メール共有ダイアログを表示するには、 TWTRShareEmailViewControllerのインスタンスを初期化して completion blockを渡してください。 completion blockには、ユーザーがEメールアドレスへのアクセスを承認した場合はEメールアドレスが渡され、拒否した場合はエラーが渡されます。
注意
ダイアログを表示する前に、まずユーザーがTwitter にログインしているかどうかをチェックする必要があります。 ユーザーがログインしていない場合、completion blockを通じてエラー(TWTRErrorDomain, TWTRErrorCodeNoAuthentication)を受け取ります。
Presenting the Share Email DialogTo present the share email dialog, initialize an instance of
|
ユーザーがアクセスを許可してEメールアドレスが使用可能になった場合、 completion block にはEメールアドレスが格納されます。
注意
ユーザーがEメールアドレスへのアクセスを承認したとしても、必ずEメールアドレスが取得できるわけではありません。 例えば、Eメールアドレスではなく電話番号を使ってTwitter に登録していた場合、Eメールアドレスは空の状態でしょう。 こうした事態が発生すると、使用できるEメールアドレスがないので completion blockはエラーを渡します。
|
If the user grants access and the email address is available, the completion block will contain the email address.
|
ユーザーがアクセスを拒否した場合、completion blockを通じてエラー (TWTRErrorDomain, TWTRErrorCodeUserDeclinedPermission)を受け取ります。
あなたのアプリがホワイトリストに登録されていないにもかかわらずTWTRShareEmailViewControllerを使おうした場合、
Twitter へのリクエストが失敗した時にエラー(TWTRAPIErrorDomain, TWTRAPIErrorCodeNotAuthorizedForEndpoint)が発生します。
あなたのアプリがホワイトリストに登録される前にトークンを付与してTWTRShareEmailViewControllerを使おうとした場合、同様のエラーが発生します。
以下にTWTRShareEmailViewControllerを使用する例を記載します:
if ([[Twitter sharedInstance] session]) {
TWTRShareEmailViewController* shareEmailViewController =
[[TWTRShareEmailViewController alloc]
initWithCompletion:^(NSString* email, NSError* error) {
NSLog(@"Email %@, Error: %@", email, error);
}];
[self presentViewController:shareEmailViewController
animated:YES
completion:nil];
} else {
// TODO: Handle user not signed in (e.g.
// attempt to log in or show an alert)
}
注意
ユーザーがメールアドレスの共有を承認もしくは拒否したタイミングで、TWTRShareEmailViewController は自分自身を解放します。 あなたが dismissViewControllerAnimated:completion:を実行する必要はありません。
注意
初期化の際には completion block を渡す必要があります。
|
If the user denies access, you will receive an error ( Attempting to use Here’s an example that shows how to use
if ([[Twitter sharedInstance] session]) {
TWTRShareEmailViewController* shareEmailViewController =
[[TWTRShareEmailViewController alloc]
initWithCompletion:^(NSString* email, NSError* error) {
NSLog(@"Email %@, Error: %@", email, error);
}];
[self presentViewController:shareEmailViewController
animated:YES
completion:nil];
} else {
// TODO: Handle user not signed in (e.g.
// attempt to log in or show an alert)
}
|