Parse - callback functions skipped - ios

I'm experiencing some issues with parse at the moment. I think that parse skips every callback.
user.password = _textfeld_Passwort.text;
user.email = _textfeld_email.text;
NSLog(#"next: signUp");
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
NSLog(#"signUp started");
if (!error) {
NSLog(#"no error!");
if (succeeded) {
NSLog(#"succes");
UIAlertView *succes = [[UIAlertView alloc] initWithTitle:#"Erfolgreich!" message:#"Registrierung abgeschlossen! Bitte bestätige den Link in der Email, die wir an dich gesendet haben! Und logge dich dann ein!" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[succes show];
[self initialerStundenplan];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:YES forKey:#"registriert"];
[defaults setObject:_textfeld_Username.text forKey:#"Username"];
[defaults setObject: Stufe_temp forKey:#"Stufe"];
[defaults setObject:_textfeld_Passwort.text forKey:#"Passwort"];
[defaults synchronize];
_button_Login.hidden = NO;
[self viewDidLoad];
} else {
NSLog(#"no succes!");
UIAlertView *fail = [[UIAlertView alloc] initWithTitle:#"Fehlgeschlagen!1" message:#"Bitte versuche es erneut!" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[fail show];
}
} else {
NSLog(#"error!");
UIAlertView *fail = [[UIAlertView alloc] initWithTitle:#"Fehlgeschlagen!2" message:#"Bitte versuche es erneut!" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[fail show];
}
}];
NSLog(#"completed / skipped");
}
I've built in some outputs. Here's the console output:
2015-01-01 20:01:05.901 Vertretungsplan[5535:2195125] next: signUp
2015-01-01 20:01:05.905 Vertretungsplan[5535:2195125] completed / skipped
So can anyone tell what I'm doing wrong or is it a Parse bug? I'm using the Parse iOS SDK 1.6.1.

Related

profile is not updating

you can download this project from this link .https://drive.google.com/file/d/1daW4veZAI21b8TqKFHauSFTboHKJceaG/view?usp=sharing
Execute this Program Clicking on button"Click here to sell your Gold now" enter the
username :hermon_yonaito#bullionscope.com
password :Wau2017?
On selecting "Profile" the ProfileViewController.m is executed.On updating the user profile updateButtonTap function is executed.It does not update.It remains buffering.How to perform profile update?
here is updateButtonTap from ProfileViewController.m
- (IBAction)updateButtonTap:(UIButton *)sender
{
[self.view endEditing:YES];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[selectedValues setObject:#"ios" forKey:#"request"];
[selectedValues setObject:[NSString stringWithFormat:#"%#",currentUser.user_id] forKey:#"user_id"];
[selectedValues setObject:postalAddressTextfield.text forKey:#"address"];
[selectedValues setObject:mobileTextfield.text forKey:#"user_mobile"];
[selectedValues setObject:question1Textfield.text forKey:#"user_answer_1"];
//[selectedValues setObject:question2Textfield.text forKey:#"user_answer_2"];
[selectedValues setObject:villageTextfield.text forKey:#"user_village"];
[GeneralWebservices webserviceCallWithData:selectedValues webserviceName:Webservice_ProfileUpdate dataToPost:imageData imageName:imageName OnCompletion:^(id returnDict, NSError *error) {
if ([returnDict[#"success"] intValue] ==1)
{
// UIAlertView* alert = [[UIAlertView alloc] init];
// [alert setTitle:#"Updated Successfully"];
// // [alert setMessage:#"Updated Successfully"];
// [alert addButtonWithTitle:#"OK"];
// [alert show];
}
else
{
UIAlertView* alert = [[UIAlertView alloc] init];
[alert setTitle:#"Updated Successfully"];
//[alert setMessage:returnDict[#"message"]];
[alert addButtonWithTitle:#"OK"];
[alert show];
}
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}];
}

Youtube videos failed to upload after upgrading to xcode7

- (void)uploadTicket:(GDataServiceTicket *)ticket
finishedWithEntry:(GDataEntryYouTubeVideo *)videoEntry
error:(NSError *)error
{
NSLog(#"ticket");
UIButton *uploadButton = (UIButton *)[backgroundImage viewWithTag:10];
UIButton *cancleButton = (UIButton *)[backgroundImage viewWithTag:20];
if (error == nil)
{
// tell the user that the add worked
NSLog(#"Video Successfully Uploaded to Youtube");
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSNumber *uploadedToYouTube = [defaults objectForKey:#"uploadedToYouTube"];
if(nil == uploadedToYouTube)
{
[defaults setObject:[NSNumber numberWithBool:YES] forKey:#"uploadedToYouTube"];
[defaults synchronize];
}
NSNumber *userOpenedYoutubeView = [defaults objectForKey:#"userOpenedYoutubeToUnlockTheme"];
if(nil != userOpenedYoutubeView)
{
// [defaults setBool:NO forKey:#"Unlock_Theme"];
[defaults setObject:[NSNumber numberWithBool:NO] forKey:#"Unlock_Theme"];
[defaults synchronize];
UIAlertView *alrtView = [[UIAlertView alloc] initWithTitle:#"Congrats...!" message:#"Your new theme is Unlocked" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alrtView show];
[alrtView release];
[self removeFromSuperview];
}
else
{
UIAlertView *alrtView = [[UIAlertView alloc] initWithTitle:#"Success...!" message:#"Your Video is successfully uploaded to Youtube" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alrtView show];
[alrtView release];
[self removeFromSuperview];
}
}
else {
NSLog(#"Fails to upload Video to Youtube");
UIAlertView *alrtView = [[UIAlertView alloc] initWithTitle:#"Sorry" message:#"Fails to upload video to Youtube. Please try again" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alrtView show];
[alrtView release];
}
mProgressView . hidden = YES;
uploadButton . hidden = NO;
cancleButton . enabled = YES;
[mProgressView setProgress: 0.0];
[self setUploadTicket:nil];
}
Every time i try to upload it is showing alert message "failed to upload". I don't get why it is showing like that. Before upgrading to Xcode 7 it works fine. Anyone know please help me.

Issue about appStoreReceiptURL

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

Xcode forgot password Parse

- (IBAction)forgotPassword:(id)sender {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Direccion de Correo" message:#"Introduzca su correo electronico:" delegate:self cancelButtonTitle:#"Cancelar" otherButtonTitles:#"Aceptar", nil];
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
[alertView show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if(buttonIndex ==1){
NSLog(#"ok button clicked in forgot password alert view");
NSString *email=[alertView textFieldAtIndex:0].text;
if ([email isEqualToString:#"email"]) {
UIAlertView *display;
display=[[UIAlertView alloc] initWithTitle:#"Email" message:#"Please enter password for resetting password" delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles: nil];
[display show];
}else{
[PFUser requestPasswordResetForEmailInBackground:email block:^(BOOL succeeded, NSError *error) {
UIAlertView *display;
if(succeeded){
display=[[UIAlertView alloc] initWithTitle:#"Correo electronico enviado" message:#"Por favor, revise su correo para resetear contraseña" delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles: nil];
}else{
display=[[UIAlertView alloc] initWithTitle:#"Correo fallido" message:#"el correo electronico no coincide con ninguno en la base de datos" delegate:nil cancelButtonTitle:#"Cancel" otherButtonTitles: nil];
}
[display show];
}];
}
}
}
Why you are going for multiple queries first to find User details if found send ResetPasswordRequest instead use completion handler for Reset Request.
[PFUser requestPasswordResetForEmailInBackground:self.txtEmail.text block:^(BOOL succeeded,NSError *error)
{
if (!error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:kAlertTitle message:[NSString stringWithFormat: #"Link to reset the password has been send to specified email"] delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
return;
}
else
{
NSString *errorString = [error userInfo][#"error"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:kAlertTitle message:[NSString stringWithFormat: #"Password reset failed: %#",errorString] delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
return;
}
}];
If user is not present Parse will respond with an error "Error: no user found with email xxxxxxxxx#xxx.com"
Regards,
Amit
In your below code,
//Here you fire the query to check for email address in your parse backend
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) { //If no error in your query then will enter below block
//the objects is array of object it gets from your parse but in your case it return's zero which implies that there is no object with that email in your parse db.
if (objects.count ==0) {
//As objects.count is zero that means no email exist so in that case you don't send email for password recovery and show a alert as below to user that email is invalid(meaning not exist)
UIAlertView *alertView =[[UIAlertView alloc]initWithTitle:#"Correo enviado" message:#"Por favor, revise su correo para resetear su contraseña" delegate:self cancelButtonTitle:#"Cancelar" otherButtonTitles:nil];
[alertView show];
} else {
//In this, else case will enter when there is objects.count greater than zero which means that email exist on db. So, in that case you would request for password recovery as below.
//Also could show a alert to let user know that request for password recovery was sent successfully.
[self sendEmail:emailTextField.text];
//the query was successful, but found 0 results
//email does not exist in the database, dont send the email
//show your alert view here
}
} else {
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
Why are again checking condition(objects == nil) as your doing in first condition(object.count == 0). Both are same so no point in showing alert for one reason. Also I ran your code and I was getting one alert to enter some text followed by a alert with title "Correo enviado".
If I misunderstand your query or anything else then please let me know.

how to use Gmail smtp in iOS app

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

Resources