iPhone 从设置中检索应用程序中的 gmail 帐户详细信息

标签 iphone objective-c ios ios5 xcode4.2

我正在制作一个应用程序,我想在其中使用 smtp 服务器发送电子邮件。

它工作正常,但如果用户没有提供正确的 gmail 帐户详细信息,例如(电子邮件 ID 和密码),则不会发送电子邮件。

我想做的是从 iPhone 的设置选项卡访问用户 gmail 帐户详细信息到我的应用程序吗?

是否可以将 Gmail 帐户详细信息检索到应用程序中?

请帮我解决这个问题。

以下是我的代码:

-(IBAction)sendemail
{
    SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
    //testMsg.fromEmail = @"Lexi mobile";//nimit51parekh@gmail.com
    testMsg.fromEmail = soundOn;
    NSLog(@"str_Uname=%@",testMsg.fromEmail);
    //str_info = [str_info stringByReplacingOccurrencesOfString:@"," withString:@""];
    testMsg.toEmail = [string_emailinfo objectAtIndex:0];
    NSLog(@"autoemail=%@",testMsg.toEmail);
    testMsg.relayHost = @"smtp.gmail.com";
    testMsg.requiresAuth = YES;
    testMsg.login = soundOn;
    NSLog(@"autoelogin=%@",testMsg.login);
    testMsg.pass = vibrateOn;
    NSLog(@"autopass=%@",testMsg.pass);
    testMsg.subject = @"Photo Sharing";
    testMsg.wantsSecure = YES; 

    NSURL *url = [[NSURL alloc]initWithString:@"http://itunes.apple.com/us/app/umix-radio/id467041430?mt=8"];
    NSString *msg2 = [NSString stringWithFormat:@"<html><b><a href=\"%@\">DOWNLOAD NOW</a></b>&nbsp&nbsp<a href=\"http://itunes.apple.com/us/app/umix-radio/id467041430?mt=8\"></a></html>",url];
    NSString *sendmsg=[[NSString alloc]initWithFormat:@"%@",msg2];
    NSLog(@"automsg=%@",sendmsg);

    testMsg.delegate = self;

    NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
                                                            sendmsg,kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];

    testMsg.parts = [NSArray arrayWithObjects:plainPart,nil];
    [testMsg send];

    // [self DeleteRowAfterSending];
    //[self performSelector:@selector(DeleteRowAfterSending) withObject:nil afterDelay:5.0];
}

-(void)messageSent:(SKPSMTPMessage *)message
{
    [message release];

    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Success" message:@"Your email is sent successfully" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
    [alert show];
    [alert release];

    NSLog(@"delegate - message sent");
}

-(void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error
{
    [message release];

    // open an alert with just an OK button
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Fail" message:@"Message sending failure" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
    [alert show];
    [alert release];

    NSLog(@"delegate - error(%d): %@", [error code], [error localizedDescription]);
}

最佳答案

What i want to do is i want to access user gamil account details from setting tab of the iPhone into my app? is it possible to do retrive the gamil account detail into the app?

不,有充分的理由:该功能将允许任何开发人员访问任何人的电子邮件帐户

那将是一个巨大的安全漏洞。

与位置服务非常相似,您只需要求用户输入他们的电子邮件地址和密码即可。并希望他们愿意使用此类个人信息来信任您的应用程序。 (假设 Apple 完全批准了您的应用。)

关于iPhone 从设置中检索应用程序中的 gmail 帐户详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10845894/

相关文章:

objective-c - 任何人都可以在一行中创建 block 和复制时解释这种异常情况吗?

ios - Sprite Kit 中同时发生两次或多次碰撞

android - ionic 2 : What happens during splash screen?

iphone - 如何在cocos2d for iphone中获取CCSprite的宽度和高度

ios - mainRunloop 上的 NSURLConnection 不工作

iphone - _myObject 与 self.myObject

ios - UITableViewCell 突出显示颜色永远不会点击外部链接

iphone - 文本字段与键盘上的 UIView 文本重叠

ios - 将屏幕坐标转换为 UIView 本地点

iphone - 将 DropBox 集成到 iphone 应用程序时出错