【问题标题】:iPhone to retrieve gmail account details in app from settingiPhone从设置中检索应用程序中的gmail帐户详细信息
【发布时间】:2012-06-01 07:07:00
【问题描述】:

我正在创建一个应用程序,我想使用 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]);
}

【问题讨论】:

    标签: iphone objective-c ios ios5 xcode4.2


    【解决方案1】:

    我想要做的是我想访问用户 gamil 帐户的详细信息 将 iPhone 的选项卡设置到我的应用程序中?有没有可能做retrive 将 gamil 帐户详细信息添加到应用中?

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

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

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

    【讨论】:

      【解决方案2】:

      让用户从 Google 向您的应用授权。在他们的开发者网站上使用 google api 检查 oauth 授权? https://developers.google.com/accounts/docs/OAuth2

      像往常一样,用户通过 google api 使用他的帐户登录并返回给您一个 access_token 以从他的帐户中获取信息,包括您需要的电子邮件。

      【讨论】:

        猜你喜欢
        • 2012-09-21
        • 2016-10-21
        • 2015-05-31
        • 1970-01-01
        • 1970-01-01
        • 2011-07-25
        • 2018-05-21
        • 2023-03-05
        • 2020-08-28
        相关资源
        最近更新 更多