I am using latest Paypal SDK for iOS, trying to test login and payment transaction in sandbox environment. I have already created a business account in Sandbox test accounts page. So I have a user email, password and a signature. But I am unable to login using those credentials. I get following error in response:
PayPal SDK: Request has failed with error: invalid_user - Incorrect username/password. Please try again. (401) | PayPal Debug-ID: c3dd83c83d43e | Details: (
{
"error_description" = "Invalid user credentials";
}
).
I am unable to understand the reason for invalid credentials. What credentials I must use in order to login sandbox account from iOS SDK? Or am I missing something in my code?
Code
- (void)viewDidLoad
{
//paypal setup
// Set up payPalConfig
_payPalConfig = [[PayPalConfiguration alloc] init];
_payPalConfig.acceptCreditCards = YES;
_payPalConfig.languageOrLocale = #"en";
_payPalConfig.merchantName = #"Merchant nmae";
_payPalConfig.merchantPrivacyPolicyURL = [NSURL URLWithString:#"https://www.paypal.com/webapps/mpp/ua/privacy-full"];
_payPalConfig.merchantUserAgreementURL = [NSURL URLWithString:#"https://www.paypal.com/webapps/mpp/ua/useragreement-full"];
_payPalConfig.languageOrLocale = [NSLocale preferredLanguages][0];
self.environment = PayPalEnvironmentSandbox;
self.payPalConfig.acceptCreditCards = NO;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES];
// Preconnect to PayPal early
[PayPalMobile preconnectWithEnvironment:self.environment];
}
- (IBAction)makePayment:(UIButton *)sender {
if([self.amount.text isEqualToString:#""])
{
[[[UIAlertView alloc] initWithTitle:#"Message" message:#"Please enter amount to proceed" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil] show];
return;
}
self.resultText = nil;
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [[NSDecimalNumber alloc] initWithString:self.amount.text];
payment.currencyCode = #"GBP";
payment.shortDescription = #"Payment for Web77";
if (!payment.processable) {
// This particular payment will always be processable. If, for
// example, the amount was negative or the shortDescription was
// empty, this payment wouldn't be processable, and you'd want
// to handle that here.
[[[UIAlertView alloc] initWithTitle:#"Message" message:#"Payment is unprocessable" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil] show];
return;
}
PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment configuration:self.payPalConfig delegate:self];
[self presentViewController:paymentViewController animated:YES completion:nil];
}
#pragma mark PayPalPaymentDelegate methods
- (void)payPalPaymentViewController:(PayPalPaymentViewController *)paymentViewController didCompletePayment:(PayPalPayment *)completedPayment {
NSLog(#"PayPal Payment Success!");
self.resultText = [completedPayment description];
[[[UIAlertView alloc] initWithTitle:#"Message" message:#"Please enter amount to proceed" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil] show];
[self sendCompletedPaymentToServer:completedPayment]; // Payment was processed successfully; send to server for verification and fulfillment
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)payPalPaymentDidCancel:(PayPalPaymentViewController *)paymentViewController {
NSLog(#"PayPal Payment Canceled");
self.resultText = nil;
[self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark Proof of payment validation
- (void)sendCompletedPaymentToServer:(PayPalPayment *)completedPayment {
// TODO: Send completedPayment.confirmation to server
NSLog(#"Here is your proof of payment:\n\n%#\n\nSend this to your server for confirmation and fulfillment.", completedPayment.confirmation);
}
Note: I have already initialized PayPalMobile with paypal client ID for sandbox environment.
Side Question:
What should merchantName contain? Should it be same as mentioned on paypal site?
#engr-anum does this information help?
While testing your app, when logging in to PayPal in the SDK's UI you should use a personal Sandbox account email and password. I.e., not your Sandbox business credentials.
You can create both business and personal Sandbox accounts on the Sandbox accounts page.
Regarding merchantName: As you'll see in the header file's comments for this property, merchantName applies only when you are using a PayPalFuturePaymentViewController. It is not relevant for a PayPalPaymentViewController.
Related
Integrated Paytm sdk 2.1 in iOS (Xcode 7) and configured to make payment .
I have a form in which amount and other fields need to filled then there is a button for Payment .
Here is code which i am using :
//Step 1: Create a default merchant config object
PGMerchantConfiguration *mc = [PGMerchantConfiguration defaultConfiguration];
//Step 2: If you have your own checksum generation and validation url set this here. Otherwise use the default Paytm urls
mc.checksumGenerationURL = #"generate checksum url";
mc.checksumValidationURL = #"checksum validation url";
//Step 3: Create the order with whatever params you want to add. But make sure that you include the merchant mandatory params
NSMutableDictionary *orderDict = [NSMutableDictionary new];
//Merchant configuration in the order object
orderDict[#"MID"] = #"abc1111";
orderDict[#"CHANNEL_ID"] = #"WAP";
orderDict[#"INDUSTRY_TYPE_ID"] = #"Education";
orderDict[#"WEBSITE"] = #"companyname";
//Order configuration in the order object
orderDict[#"TXN_AMOUNT"] = #"100";
orderDict[#"ORDER_ID"] = [Feepayment generateOrderIDWithPrefix:#"111"];
orderDict[#"REQUEST_TYPE"] = #"DEFAULT";
orderDict[#"CUST_ID"] = #"abc7777";
PGOrder *order = [PGOrder orderWithParams:orderDict];
//Step 4: Choose the PG server. In your production build dont call selectServerDialog. Just create a instance of the
//PGTransactionViewController and set the serverType to eServerTypeProduction
[PGServerEnvironment selectServerDialog:self.view completionHandler:^(ServerType type)
{
PGTransactionViewController *txnController = [[PGTransactionViewController alloc] initTransactionForOrder:order];
//show title var
UIView *mNavBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,44)];
mNavBar.backgroundColor = [UIColor grayColor];
txnController.topBar = mNavBar;
//Cancel button
UIButton *mCancelButton = [[UIButton alloc] initWithFrame:CGRectMake(5, 2, 70, 40)];
[mCancelButton setTitle:#"Cancel" forState:UIControlStateNormal];
mCancelButton.titleLabel.textColor = PURPLE_COLOR;
[mCancelButton setFont:[UIFont fontWithName:#"Helvetica-Bold" size:15.0]];
txnController.cancelButton = mCancelButton;
//add title
UILabel *mTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2 - 10, 1, 100, 50)];
[mTitleLabel setText:#"Payment"];
[mTitleLabel setFont:[UIFont fontWithName:#"Helvetica-Bold" size:15.0]];
mTitleLabel.textColor = [UIColor whiteColor];
[mNavBar addSubview:mTitleLabel];
if (type!=eServerTypeNone) {
txnController.serverType = type;
txnController.merchant = mc;
txnController.loggingEnabled = YES;
txnController.sendAllChecksumResponseParamsToPG = YES;
txnController.delegate = self;
[self showController:txnController];
}
}];
//show controller method
-(void)showController:(PGTransactionViewController *)controller {
if (self.navigationController != nil)
[self.navigationController pushViewController:controller animated:YES];
else
[self presentViewController:controller animated:YES
completion:^{
}];
}
//remove controller
-(void)removeController:(PGTransactionViewController *)controller {
if (self.navigationController != nil)
[self.navigationController popViewControllerAnimated:YES];
else
[controller dismissViewControllerAnimated:YES
completion:^{
}];
}
#pragma mark PGTransactionViewController delegate
- (void)didSucceedTransaction:(PGTransactionViewController *)controller
response:(NSDictionary *)response {
DEBUGLOG(#"ViewController::didSucceedTransactionresponse= %#", response);
NSString *title = [NSString stringWithFormat:#"Your order was completed successfully. \n %#", response[#"ORDERID"]];
[[[UIAlertView alloc] initWithTitle:title message:[response description] delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil] show];
[self removeController:controller];
}
- (void)didFailTransaction:(PGTransactionViewController *)controller error:(NSError *)error response:(NSDictionary *)response {
DEBUGLOG(#"ViewController::didFailTransaction error = %# response= %#", error, response);
if (response)
{
[[[UIAlertView alloc] initWithTitle:error.localizedDescription message:[response description] delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil] show];
}
else if (error)
{
[[[UIAlertView alloc] initWithTitle:#"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil] show];
}
[self removeController:controller];
}
- (void)didCancelTransaction:(PGTransactionViewController *)controller error:(NSError*)error response:(NSDictionary *)response {
DEBUGLOG(#"ViewController::didCancelTransaction error = %# response= %#", error, response);
NSString *msg = nil;
if (!error) msg = [NSString stringWithFormat:#"Successful"];
else msg = [NSString stringWithFormat:#"UnSuccessful"];
[[[UIAlertView alloc] initWithTitle:#"Transaction Cancel" message:msg delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil] show];
[self removeController:controller];
}
- (void)didFinishCASTransaction:(PGTransactionViewController *)controller response:(NSDictionary *)response {
DEBUGLOG(#"ViewController::didFinishCASTransaction:response = %#", response);
}
Here is screenshot while using staging directly showing this page :
*Note - Actually i am trying for staging not for production .
When i execute then it doesnt showing Paytm feepayment form instead it showing orderid and amount with transaction id dirctly .
How to open Paytm payment form when user enter fee amount in the form then it should calcualte the amount with extraa tax and then clicking on Fee payment button it should open PAYTM PAYMENT FORM.
PLEASE HELP ME TO SOLVE THIS PROBLEM ( I HAVE GO THROUGH THE PAYTM SDK DOC STEP BY STEP BUT DINT ABLE TO FIND IT ).
THANKS.
Important : **As far as checksumGenerationURL and checksumValidationURL is concerned , we need to create it . Initially i tried to use from Paytm but it dint work so finally our server team did it , this is most important point for Integrating Paytm
Finally , Solved by testing it on the Production and its working fine . As far as Staging server is concerned i guess there is hard coded information is in the sdk so hope in the next version of PGSDK we could test it on Staging too.
Thanks .
#Pradeep k ... thank you very much for all your valuable support .
Have you populated the mc.checksumGenerationURL and mc.checksumValidationURL properly? Also there is a 2.7 version of the SDK that you should be using. Ask your Paytm contact point for the latest iOS SDK.
Now about the amount, Paytm does not calculate the tax. You have to add it to the amount that you are sending to Paytm.
I am doing R&D on How to integrate PayPal/Apple Pay payment module in iOS App.
For example in my app i want to integrate PayPal/Apple pay for payment, then what should I do ? What are the process.
IF anyone can guide how to do it. Please suggest me the steps.
Any reference link then also welcome.
It depends on the payment solution you've integrated.
PayPal will support funding source of account balance or credit card/debit card/bank that is linked to the account. While unlike the PayPal wallet, there's no "balance" thing in the Apple Pay/Apple Wallet, which works purely with card tokenization (cards that you setup in your Wallet App).
In this use case, your app won't necessarily to check whether $20 is available in the wallet (either PayPal or Apple Pay), instead it will initiate the payment request, and get the response from the payment gateway to process your orders
in AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[PayPalMobile initializeWithClientIdsForEnvironments:#{PayPalEnvironmentProduction : #"YOUR_CLIENT_ID_FOR_PRODUCTION",
PayPalEnvironmentSandbox : #"AeB0tbkw-z4Ys3NvxekUZxnVNk26WXRodQBETFG4x-HtQAuqBf5k4edWOn2zia_l8RWBFJGEUNSVWJWg"}];
return YES;
}
with your Controller
in your .h File set delegate
#interface MyCart : UITableViewController
#property(nonatomic, strong, readwrite) PayPalConfiguration *payPalConfig;
in your .m File
- (void)viewDidLoad {
NSString *environment=#"sandbox";
self.environment = environment;
[PayPalMobile preconnectWithEnvironment:environment];
_payPalConfig = [[PayPalConfiguration alloc] init];
_payPalConfig.acceptCreditCards = YES;
_payPalConfig.merchantName = #"ScanPay";
_payPalConfig.merchantPrivacyPolicyURL = [NSURL URLWithString:#"https://www.paypal.com/webapps/mpp/ua/privacy-full"];
_payPalConfig.merchantUserAgreementURL = [NSURL URLWithString:#"https://www.paypal.com/webapps/mpp/ua/useragreement-full"];
_payPalConfig.languageOrLocale = [NSLocale preferredLanguages][0];
_payPalConfig.payPalShippingAddressOption = PayPalShippingAddressOptionPayPal;
}
Code with purchase button event
-(IBAction)btnCheckoutTapped
{
// UIAlertView *alt=[[UIAlertView alloc]initWithTitle:#"ScanPay" message:#"Under Development" delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
// [alt show];
NSDecimalNumber *subtotal = [[NSDecimalNumber alloc]initWithDouble:Price];
// Optional: include payment details
NSDecimalNumber *shipping = [[NSDecimalNumber alloc] initWithString:#"0.00"];
NSDecimalNumber *tax = [[NSDecimalNumber alloc] initWithString:#"0.00"];
PayPalPaymentDetails *paymentDetails = [PayPalPaymentDetails paymentDetailsWithSubtotal:subtotal
withShipping:shipping
withTax:tax];
NSDecimalNumber *total = [[subtotal decimalNumberByAdding:shipping] decimalNumberByAdding:tax];
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = total;
payment.currencyCode = #"USD";
payment.shortDescription = #"You Pay";
payment.paymentDetails = paymentDetails; // if not including payment details, then leave payment.paymentDetails as nil
if (!payment.processable) {
// This particular payment will always be processable. If, for
// example, the amount was negative or the shortDescription was
// empty, this payment wouldn't be processable, and you'd want
// to handle that here.
}
// Update payPalConfig re accepting credit cards.
self.payPalConfig.acceptCreditCards = YES;
PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment
configuration:self.payPalConfig
delegate:self];
[self presentViewController:paymentViewController animated:YES completion:nil];
}
PayPalPaymentDelegate methods
- (void)payPalPaymentViewController:(PayPalPaymentViewController *)paymentViewController didCompletePayment:(PayPalPayment *)completedPayment {
NSLog(#"PayPal Payment Success!");
[self ErrorWithString:#"PayPal Payment Success!"];
self.resultText = [completedPayment description];
//[self showSuccess];
[self sendCompletedPaymentToServer:completedPayment]; // Payment was processed successfully; send to server for verification and fulfillment
[self dismissViewControllerAnimated:YES completion:nil];
ReceiptScreen *obj=[self.storyboard instantiateViewControllerWithIdentifier:#"ReceiptScreen"];
[self.navigationController pushViewController:obj animated:YES];
}
- (void)payPalPaymentDidCancel:(PayPalPaymentViewController *)paymentViewController {
NSLog(#"PayPal Payment Canceled");
self.resultText = nil;
// self.successView.hidden = YES;
[self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark Proof of payment validation
- (void)sendCompletedPaymentToServer:(PayPalPayment *)completedPayment {
// TODO: Send completedPayment.confirmation to server
NSLog(#"Here is your proof of payment:\n\n%#\n\nSend this to your server for confirmation and fulfillment.", completedPayment.confirmation);
}
PayPal - Here is complete PayPal sample code suggested by https://developer.paypal.com, PayPal Developer Guide and Sample code
Apple Pay - You can check it apple's demo code
I hope you are looking for it. :)
I'm trying to set up an anonymous login so my users don't have to create an account an account on the eJabberd server to use the chat room. The configuration for the server in the ejabberd.cfg is:
{host_config, "bubble", [{auth_method, anonymous},
{anonymous_protocol, login_anon}]}.
My method to connect the client to the XMPPStream:
- (BOOL)connect {
[self setupStream];
if (![self.xmppStream isDisconnected]) {
return YES;
}
if (![PFUser currentUser]) {
return NO;
}
NSString *currentUserId = [NSString stringWithFormat:#"%##bubble",[PFUser currentUser].objectId];
[self.xmppStream setMyJID:[XMPPJID jidWithString:currentUserId]];
self.xmppStream.hostName = kJABBER_HOSTNAME;
NSError *error = nil;
if (![self.xmppStream connectWithTimeout:10 error:&error]) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Error"
message:[NSString stringWithFormat:#"Can't connect to server %#", [error localizedDescription]]
delegate:nil
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alertView show];
return NO;
}
return YES;
}
As well as the xmppStreamDidConnect method:
- (void)xmppStreamDidConnect:(XMPPStream *)sender {
self.isOpen = YES;
NSError *error = nil;
if(![self.xmppStream authenticateAnonymously:&error]) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Error"
message:[NSString stringWithFormat:#"Can't connect to server %#", [error localizedDescription]]
delegate:nil
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alertView show];
}
}
When I try to login into the server, it keep on getting "The server does no support anonymous authentication".
Not sure what I'm doing wrong here, please let me know your thoughts.
From the XMPPFramework documentation:
If you wish to use anonymous authentication, you should still set myJID prior to calling connect. You can simply set it to something like "anonymous#domain", where "domain" is the proper domain. After the authentication process, you can query the myJID property to see what your assigned JID is.
Make sure that the settings on the server allow anonymous login as well.
If you don't have access to the serve configuration you can still check if the server allows anonymous login using something like:
- (void)xmppStreamDidConnect:(XMPPStream*)sender
{
self.isXmppConnected = YES;
if ([self.xmppStream supportsAnonymousAuthentication]) {
NSError* error = nil;
//the server does support anonymous auth
[self.xmppStream authenticateAnonymously:&error];
}
else {
NSLog(#"The server does not support anonymous authentication");
}
}
Be sure to place it in the didConnect delegate method, as it needs to be connected first.
I am trying to convert my paid app to free version with IAP , so basically I need to check if users bought previous version then unlock IAP item , I am not sure I am doing right here or not ! even is it possible to check and track 'appStoreReceiptURL' in development process ? here is my code :
NSURL* url = [[NSBundle mainBundle] appStoreReceiptURL];
NSLog(#"receiptUrl %#",[url path]);
NSError* err = nil;
if (![url checkResourceIsReachableAndReturnError:&err]){
SKReceiptRefreshRequest* request = [[SKReceiptRefreshRequest alloc] initWithReceiptProperties:nil];
request.delegate = self;
[request start];
}
-(void)requestDidFinish:(SKRequest*)request{
if([request isKindOfClass:[SKReceiptRefreshRequest class]]){
NSLog(#"YES, You purchased this app");
}
}
-(void)request:(SKRequest*)request didFailWithError:(NSError *)error{
NSLog(#"NO, you need to buy it ");
}
Now I am able to login with my Apple ID,and after I signed in it tells me YES, You purchased this app", and yes I really bought my app ! , I am going to make sure everything is alright .
Does this process should happen in every update ?
Here is a simple solution
#import <StoreKit/StoreKit.h>
Don't forget to add its delegates
<SKPaymentTransactionObserver, SKProductsRequestDelegate>
Payment Validation
- (IBAction)boughtIt:(id)sender {
NSURL* url = [[NSBundle mainBundle] appStoreReceiptURL];
NSLog(#"receiptUrl %#",[url path]);
NSError* err = nil;
if (![url checkResourceIsReachableAndReturnError:&err]){
SKReceiptRefreshRequest* request = [[SKReceiptRefreshRequest alloc] initWithReceiptProperties:nil];
request.delegate = self;
[request start];
_activity.hidden = NO;
}
}
-(void)requestDidFinish:(SKRequest*)request{
if([request isKindOfClass:[SKReceiptRefreshRequest class]]){
NSLog(#"YES, You purchased this app");
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Congrats !" message:#"Welcome To The World Of Dinosaurs" delegate:self
cancelButtonTitle:#"Cancel" otherButtonTitles:nil, nil];
[alert show];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"isPurchased"];
[[NSUserDefaults standardUserDefaults] synchronize];
_activity.hidden = YES;
[self dismissViewControllerAnimated:YES completion:nil];
}
}
- (void)request:(SKRequest*)request didFailWithError:(NSError *)error{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Sorry !" message:#"It seems you did not purchase this app before, if you like to unlock all content and features please purchase Paleontologist Pack" delegate:self
cancelButtonTitle:#"Cancel" otherButtonTitles:nil, nil];
[alert show];
_activity.hidden = YES;
// [self dismissViewControllerAnimated:YES completion:nil];
NSLog(#"NO, you need to buy it ");
}
This works only if a user PURCHASED the application , it doesn't work for redeem codes
I am new to Xcode I need an app to send a email. Background: the destination email Id is typed in a text and by clicking the send button the message body Sample should go to the destination Email ID I tried this code in the function button clicked but it is not working when ever i try this code I get error in function can any one guide me with a step by step tutorial
mailTransfer[673:207] delegate - error(-5): timeout sending message
2014-07-05 10:54:05.393 mailTransfer[673:207] * stopping watchdog * I had added the SMTP files from google documents ... any other way to correct this code
- (IBAction)sendMessageInBack:(id)anObject
{
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = #"Yours mail ids";
testMsg.toEmail = emailField.text;
testMsg.relayHost = #"smtp.gmail.com";
testMsg.requiresAuth = YES;
testMsg.login = #"Your mail ids";
testMsg.pass = #"id password";
testMsg.subject = #"Test application ";
testMsg.wantsSecure = YES;
testMsg.delegate = self;
NSDictionary *plainPart = [NSDictionarydictionaryWithObjectsAndKeys:#"text/plain",kSKPSMTPPartContentTypeKey,#"Sample",kSKPSMTPPartMessageKey,#"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
testMsg.parts = [NSArray arrayWithObjects:plainPart,nil];
[testMsg send];
}
-(void)messageSent:(SKPSMTPMessage *)message{
[message release];
NSLog(#"delegate - message sent");
}
-(void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error{
[message release];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Unable to send email" delegate:self cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
[alert release];
NSLog(#"delegate - error(%d): %#", [error code], [error localizedDescription]);
}
in SKPSMTPMessage.m
update the following line
CFDictionarySetValue(sslOptions,kCFStreamSSLLevel,kCFStreamSocketSecurityLevelTLSv1);
with
CFDictionarySetValue(sslOptions, kCFStreamSSLLevel, kCFStreamSocketSecurityLevelSSLv3);
Download SMTP framework and import SKPSMTPMessage class..
#import "SKPSMTPMessage.h"
-(void)sendEmailVideo:(NSString*)_toEmailAddress andCC:(NSString*)ccEmail
{
#try
{
// Message =[data getContentOfPanic];
NSData *webData = [NSData dataWithContentsOfURL:videoURL];
SKPSMTPMessage *emailMessage = [[SKPSMTPMessage alloc] init];
emailMessage.fromEmail=#"nikki.varsha#gmail.com";//sender email address
emailMessage.toEmail=_toEmailAddress;
//receiver email address
emailMessage.relayHost=#"smtp.gmail.com";
//emailMessage.ccEmail =ccEmail;
emailMessage.requiresAuth = YES;
emailMessage.login = #"nikki.varsha#gmail.com"; //sender email address
emailMessage.pass = #"123";
//sender email password
emailMessage.subject =#"Panic Video Message";
emailMessage.wantsSecure = YES;
emailMessage.delegate = self;
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:#"text/plain",kSKPSMTPPartContentTypeKey,
Message,kSKPSMTPPartMessageKey,#"8bit", kSKPSMTPPartContentTransferEncodingKey,nil];
NSDictionary *vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:#"text/directory;\r\n\tx-unix-mode=0644;\r\n\tname=\"Video.mov\"",kSKPSMTPPartContentTypeKey,
#"attachment;\r\n\tfilename=\"Video.mov\"",kSKPSMTPPartContentDispositionKey,[webData encodeBase64ForData],kSKPSMTPPartMessageKey,#"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
emailMessage.parts=[NSArray arrayWithObjects:plainPart,vcfPart,nil];
dispatch_queue_t backgroundVideoQueue = dispatch_queue_create("com.VideoQue", 0);
dispatch_sync(backgroundVideoQueue, ^{
[emailMessage send];
});
}
#catch (NSException *exception)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"No Host" message:#"No Reciever Email Ids Available! " delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
}
}
pragma mark - sendEmail delegate (SKPSMTPMessage)
-(void)messageSent:(SKPSMTPMessage *)message
{
NSLog(#"delegate - Email sent");
NSLog(#"Mesg %#",message);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Email sent." message:nil delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles: nil];
[alert show];
}
-(void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error
{
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(#"err=%#" ,message);
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Error"
message:#"Unable to send email Please Check EmailId & Password"
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles: nil];
[alert show];
});
}
in SKPSMTPMessage.m file do change the following line
Remove this line
//CFDictionarySetValue(sslOptions,kCFStreamSSLLevel,kCFStreamSocketSecurityLevelTLSv1);
Add this line
CFDictionarySetValue(sslOptions, kCFStreamSSLLevel, kCFStreamSocketSecurityLevelSSLv3);
Thanks