Trouble connecting to a google apps server via MailCore - ios

I'm trying to connect to Google Apps email server via IMAP. The code I am using below, every time I try to connect I get the error: Parse error Anyone know the source of this error?
int port = 993;
CTCoreAccount *account = [[CTCoreAccount alloc] init];
BOOL success = [account connectToServer:#"imap.gmail.com"
port:port
connectionType:CTConnectionTypeStartTLS
authType:CTImapAuthTypePlain
login:login
password:password];
NSLog(#"Port: %d",port);
if (!success) {
NSLog(#"Connection failed, error: %#",[account.lastError localizedDescription]);
}
else {
NSLog(#"Connection succeeded");
}

There were two issues simultaneously going on here. The first was that my network had a firewall and that was the source of the Parse Error.
Second, when you need to connect to Google Maps IMAP server, you'll need to use the CTConnectionTypeTLS instead of CTConnectionTypeStartTLS, because the second one makes the server go bonkers.

Related

ConnectionID is in incorrect formate. SignalR

I usesignalR latest library. I downloaded signalR library from gitHub SignalR gitHub link and installed pod file in my app. I am working on iOS end. I don't know about asp.net. The only url is provided to me for integration. Here is my code
__weak SRConnection *connection = [SRConnection connectionWithURL:SIGNALR_PATH];
[connection addValue:[[NSUserDefaults standardUserDefaults] objectForKey:kAccessToken] forHTTPHeaderField:#"MyAuthentication"];
connection.received = ^(NSString * data) {
NSLog(#"%#",data);
};
connection.started = ^{
[connection send:#"hello world"];
};
[connection start];
Connection open successfully but When I get try to send message it gives me an error "The ConnectionId is in incorrect format".
I am using latest library of signalR. I don't know what I need to authorised. Is only url enough for that? Or will need to add accessToken that I get on login?.
Please help me what I need for integrating signalR. I searched a lot but couldn't find any clear information.

iOS8 Touch ID getting error : Pending UI mechanism already set

Description of error is below:
Error Domain=com.apple.LocalAuthentication Code=-1000 "Pending UI mechanism already set." UserInfo=0x17406b0c0 {NSLocalizedDescription=Pending UI mechanism already set.}
I am also trying Apple's Sample Example app and getting same error. Previously it was working fine, but it has stopped working suddenly ad not working. Please help.
I am using iPhone 6 with iOS 8.1
This code just worked fine for me.
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = #"String explaining why app needs authentication";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
// User authenticated successfully, take appropriate action
NSLog(#"User authenticated successfully, take appropriate action");
} else {
// User did not authenticate successfully, look at error and take appropriate action
NSLog(#"User did not authenticate successfully, look at error and take appropriate action");
}
}];
} else {
// Could not evaluate policy; look at authError and present an appropriate message to user
NSLog(#"Could not evaluate policy: %#",authError);
}
Don't forget to import Local Authentication framework <LocalAuthentication/LAContext.h>. Hope this will solve your issue.
Try rebooting your phone.
I also started getting this error and decided to see if other apps were affected. I have both Dropbox and Mint set up for Touch ID. Sure enough Touch ID wasn't working for them either and they were falling back to passcodes.
I rebooted my phone and it started working again, so it would seem the Touch ID can bug out and stop working. I'm on iOS 8.2 btw.
I guess the proper way to handle this condition is like those apps do and fallback to password / passcode.

Strongloop iOS User Creation Error

I'm trying to create and save a test user in server with this code:
LBRESTAdapter *adapter = ((AppDelegate *)[[UIApplication sharedApplication] delegate]).adapter;
if (adapter) {
TeacherRepository *repo = (TeacherRepository *)[adapter repositoryWithClass:[TeacherRepository class]];
if (repo) {
Teacher *st = (Teacher *)[repo createUserWithEmail:#"test#test.com" password:#"test"];
if (st) {
[st saveWithSuccess:^{
NSLog(#"Saved in server!");
} failure:^(NSError *error) {
NSLog(#"Error: %#", error.description);
}];
}
}
}
but I keep on getting this error response:
Error Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299), got 404"
I have searched for this error and similar others, but couldn't find anything that would solve my problem, so what could be causing this?
The HTTP Status Code of 404 means that the resource was not found:
404 Not Found
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.
It would appear that there is an error in the building of the URL in your AFNetworking code. You haven't shared that portion of code, so it's hard to comment on the specifics. I think if you log the entire error object (not just error.description) it will show you what URL it attempted to use unsuccessfully.

ios-Facebook SDK 3.0 Error 5 When Posting Status Update

I am trying out adding facebook integration in an app using the new (beta) facebook ios sdk 3.0. All I would like to is post a status update to facebook. I used a FBLoginView to login to facebook. I put my app id in the plist as instructed on facebook. I put in some code to post to facebook.
(void)viewDidLoad
{
[super viewDidLoad];
NSArray *perms;
perms = [NSArray arrayWithObjects:#"status_update", nil];
FBLoginView *loginview =
[[FBLoginView alloc] initWithPermissions:perms];
loginview.frame = CGRectOffset(loginview.frame, 5, 5);
loginview.delegate = self;
[self.view addSubview:loginview];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)poststatus:(UIButton *)sender {
NSString *message = [NSString stringWithFormat:#"Test staus update"];
[FBRequestConnection startForPostStatusUpdate:message
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[self showAlert:message result:result error:error];
}];
}
- (void)showAlert:(NSString *)message
result:(id)result
error:(NSError *)error {
NSString *alertMsg;
NSString *alertTitle;
if (error) {
alertMsg = error.localizedDescription;
alertTitle = #"Error";
} else {
NSDictionary *resultDict = (NSDictionary *)result;
alertMsg = [NSString stringWithFormat:#"Successfully posted '%#'.\nPost ID: %#",
message, [resultDict valueForKey:#"id"]];
alertTitle = #"Success";
}
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:alertTitle
message:alertMsg
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alertView show];
}
The odd thing is, this code works ONCE. After authenticating the user for the first time, I can post ONE status update successfully. After that, all subsequent attempts will fail with a FBiOSSDK error 5 (in the console, Error: HTTP status code:400). The only way to fix this is to remove the app from the facebook account and re-authenticate. I'm not sure what the problem is. I looked online for solutions but couldn't find anything. If anyone knows how to fix this, please let me know. Thanks
com.facebook.sdk error 5 is always irritating while working with Facebook iOS sdk. Most of the times it comes with addional in console Error: HTTP status code:400. Its a perception that there is a bug in Facebook iOS sdk that produces this error randomly. I think this error occurs for some certain reasons and sdk do not provide actual reason of error when it occurs.
Several Possible Reasons
Every request in sdk is accomplished with completion blocks that we actually pass as argument in completionHandler. This error occurs when a block is in progress and made another request. A simple example might be If you have written request to post on Facebook (startForPostStatusUpdate::) on some button action. On single button tap it would work fine but if you double tap on button it will throw this error com.facebook.sdk error 5
If you are trying to post when your current session is not opened. e.g. Once sign in with Facebook then kill the app then reopen and then try to share on Facebook, Result -> com.facebook.sdk error 5. In this case try to reopen session using
Facebook do not allow same status to be posted repeatedly, they think it might be some kind of spam e.g. If you are trying to update status and you have hard coded a string lets say #”This is a test status update” you are posing again and again. After 5 to 10 attempts they wont allow you to do anymore. Resulting com.facebook.sdk error 5. If this is the scenario you should change your status string and try updating.
Facebook has defined a limit for a particular user to post status using sdk. e.g If you are trying to update status and you have done lets say 15 to 20 status updates. They wont let you do more Resulting -> com.facebook.sdk error 5. In this scenario try to unauthorize the app from your Facebook account and reauthorize it OR try using other Facebook account
It seems there might be no answer to the issue. I have checked FB samples coming with SDK, in these examples also the same error happens. So it means after few status updates (15-20) Facebook reaches limits for that particular user. If you log-out for that user and log-in as another user, you can successfully post.
If I will find any extension to limit settings I will reply.
Also Facebook doesn't allow for the same Post.
Use a proxy !
FB ios SDK is just a wrap to an HTTP request to graph.facebook.com/....?access_token=.....
So you can easily replicate the request or use an HTTP proxy to see the real server answer (which is not error 5 !).

TURN Connection using the iOS XMPPFramework and an OpenFire Server

Problem : How can I get a successful TURN Connection using the iOS XMPPFramework and an OpenFire Server. I want to be able to send and recieve files.
Note : The base of my code is from the following tutorial : http://mobile.tutsplus.com/tutorials/iphone/building-a-jabber-client-for-ios-server-setup/
Update 13th April 2012 : After more research, I think the real relevant code I need to display in this question is this ...
This is where the TURNSocket attempts to connect
XMPPJID *jid = [XMPPJID jidWithString:#"myFriendsUsername#beta.myCompany.co.uk"];
NSLog(#"Attempting TURN connection to %#", jid);
TURNSocket *turnSocket = [[TURNSocket alloc] initWithStream:[self xmppStream] toJID:jid];
[turnSockets addObject:turnSocket];
[turnSocket startWithDelegate:self delegateQueue:dispatch_get_main_queue()];
[turnSocket release];
However, when I debug through the code, in TURNSocket I get to a comment which states that "We were unable to find a single proxy server from our list". This is because the Array 'streamhosts' never gets populated. What could be the issue? Is there some XML somewhere that should tell me the problem? Is the issue likely to be with OpenFire?
The problem is caused if a full jID with a resource is not provided to TurnSocket.m! This is passed in in viewDidLoad of SMChatViewController
e.g Use
friendsUsername#beta.myCompany.co.uk/spark
rather than
friendsUsername#beta.myCompany.co.uk
My progress on this project can be followed here
This is the class method of TURNSocket you call to
populate the proxy candidates of the TURNSocket
stream host. So you should put streamhost back to
what it was before stream-host.
+ (void)setProxyCandidates:(NSArray *)candidates;
[TURNSocket setProxyCandidates:#["host1.somedomain.com", #"host2.someotherdomain.com"]];
In processRequestResponse.m in TurnSocket, the name of the streamhost element wasn't what OpenFire was giving me. I have changed it from this
NSXMLElement *streamhostUsed = [query elementForName:#"streamhost-used"];
to this
NSXMLElement *streamhostUsed = [query elementForName:#"streamhost"];
However, I now have a new error which I am starting a new question for ... OpenFire/XMPP 503 service-unavailable error (XEP-0065 using iOS XMPPFramework)
Update 20/4/2012 : I now believe this answer is wrong! If it was working correctly, streamhostUsed would be there, rather than streamhost with an error!

Resources