I am developing a photo sharing application on iOS that shares pictures on various social networks including Flickr. In order to authorise the app and to upload photos on a Flickr photo-stream I use FlickrKit.
After successfully authorising the app I try to post the selected picture with the following code:
UIImage *img = self.itemsToShare[currentItem];
NSDictionary *uploadArgs = #{#"title": #"Test Photo", #"description": #"A Test Photo via FlickrKitDemo", #"is_public": #"0", #"is_friend": #"0", #"is_family": #"0", #"hidden": #"2"};
self.uploadOp = [[FlickrKit sharedFlickrKit] uploadImage:img args:uploadArgs completion:^(NSString *imageID, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
} else {
NSString *msg = [NSString stringWithFormat:#"Uploaded image ID %#", imageID];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Done" message:msg delegate:nil cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
}
});
}];
My problem is that the following error occurs:
2014-07-02 10:16:23.710 myApp[805:3507] <?xml version="1.0" encoding="utf-8" ?>
<rsp stat="fail">
<err code="95" msg="SSL is required" />
</rsp>
Does anyone have an idea where do I set an SSL connection for FlickrKit?
Thank you very much,
Granit
During my research I saw that the Flickr API is now SSL-Only form June 27th 2014. The fix is to change upload URL in FKImageUploadNetworkOperation.m file to:
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:#"https://up.flickr.com/services/upload/"]];
[request setHTTPMethod:#"POST"];
all you need to update is the URL, from HTTP to HTTPS:
https://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=.............&photoset_id=...............&format=rest
worked for me!
Simply you need to replace http to https in flickr API, due to secure connection issue.
Related
I am using SLRequest to send user's video to twitter. After finishing the post request, I want to inform the user whether the upload is successful. But if I show a UIAlertView inside the SLRequestHandler, the system simply hangs and doesn't show the alert view at all. Is it a no-go to have a UIAlertView inside the SLRequestHandler? What is the better way to show a custom message based on the result of the post request?
Here is my sample code:
SLRequest *postRequest2 = [SLRequest
requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:requestURL2 parameters:message2];
postRequest2.account = twitterAccount;
[postRequest2
performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse, NSError *error)
{
if (error != nil) {
NSLog(#"error: %#", error);
}
else {
UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:#"Success!"
message:#"Your video is now available in your Twitter account"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[theAlert show];
}
}];
All UI related operations must be on the main thread.
Would you try to dispatch on the main thread your alert view?
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:#"Success!" message:#"Your video is now available in your Twitter account" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[theAlert show];
});
Please note that UIAlertView is deprecated since iOS 8, and the use of UIAlertViewController is recommended.
You are trying to show the alert message in a block.
Alerts are UI Thread (main thread) controls. So, modify else part and show your alert in dispatch_async, it will work.
dispatch_async(dispatch_get_main_queue(), ^{
[theAlert show];
});
This question already has answers here:
Why isn't UIAlertView Showing?
(4 answers)
Closed 7 years ago.
I am using parse for sign-in/sign-up process.
Everything is working fine. Until user gives wrong details.
In else part of Parse Login I have written:
self.view.userInteractionEnabled = YES;
[SVProgressHUD dismiss];
// The login failed. Check error to see why.
NSString *message = [NSString stringWithFormat:#"%#",[error valueForKey:#"Error"]];
UIAlertView *myalert = [[UIAlertView alloc]initWithTitle:#"SO" message:message delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles: nil];
[myalert show];
I checked after putting breakpoints in every line.
After executing the 3rd Line i.e. NSSString *message the control doesn't go for alert it directly shows me UI without any alert box.
And In Log I am getting
[Error]: invalid login parameters (Code: 101, Version: 1.7.5)
I doesn't know what to do ? I have written only this code in else part.
I am using Parse Code :
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error)
{
if (!error)
{
// Hooray! Let them use the app now.
}
else
{
NSString *errorString = [error userInfo][#"error"]; // Show the errorString somewhere and let the user try again.
}
}];
and In else part I want to show and alertView
Try this :
UIAlertView *myalert = [[UIAlertView alloc]initWithTitle:#"SO" message:message delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles: nil];
dispatch_async(dispatch_get_main_queue(), ^(void){
[myalert show];
});
Try this code
NSString *errorString;
UIAlertView *AV;
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) { // Hooray! Let them use the app now.
} else { errorString = [error userInfo][#"error"]; // Show the errorString somewhere and let the user try again.
AV = [[UIAlertView alloc]initWithTitle:#"SO" message:errorString delegate:nil cancelButtonTitle:#"Cancel" otherButtonTitles:nil, nil];
[AV show];
}
}];
try to call main thread first then create the UIAlert in it
coz mostly thats happen when you are not in the main thread
hope this solve your problem goodluck
I am using box SDK V2 and the folder picker present in the sample app. I do not need any upload or download facility. I just need to get the file's ShareLink.
I am successfully displaying the filename and everything but not the share link.
I am getting a NULL.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
BoxItem *item = (BoxItem *)[self.folderItemsArray objectAtIndex:[indexPath row]];
NSLog(#"item type : %# : %# : %# ", item.type, item.name, item.sharedLink);
}
Am using this code.(from sample app)
I am getting results like:
1.item type : file : dummy.pdf : (null)
2. item type : file : presentations-tips.ppt : (null)
I am not getting the sharedlink.
first reaction: may be sharedlinks are not created for those files, So:
I went to my box account and created share links for those files through my desktop.
and rechecked. but got same result.
I need the shared link badly. Please help. Thanks in advance
I got the solution for getting shared link of file. Write following lines of code where you want to get shared link.
BoxFileBlock successfulShare = ^(BoxFile *file)
{
dispatch_sync(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"File Share Successful" message:[NSString stringWithFormat:#"Shared link: %#", [file.sharedLink objectForKey:#"url"]] delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
});
};
BoxAPIJSONFailureBlock failedShare = ^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSDictionary *JSONDictionary)
{
BOXLog(#"status code: %i", response.statusCode);
BOXLog(#"share response JSON: %#", JSONDictionary);
};
BoxFilesRequestBuilder *builder = [[BoxFilesRequestBuilder alloc] init];
BoxSharedObjectBuilder *sharedBuilder = [[BoxSharedObjectBuilder alloc] init];
sharedBuilder.access = BoxAPISharedObjectAccessOpen;
builder.sharedLink = sharedBuilder;
[[BoxSDK sharedSDK].filesManager editFileWithID:YOUR_FILE.modelID requestBuilder:builder success:successfulShare failure:failedShare];
I'm building an app that allows the user to export en import data files and send them by e-mail.
So I've created a data file type with extension ".myAppExtension".
At first time everythings goes well. I can't export and send an e-mail. And when I open the e-mail, the method does work.
-(BOOL) application:(UIApplication *)application handleOpenURL:(NSURL *)url {
if (url != nil && [url isFileURL]) {
NSLog(#"%#",url);
NSLog(#"%#",[url pathExtension]);
if([[[url pathExtension] lowercaseString] isEqualToString:[#"myAppExtension" lowercaseString]]){
//Deal with received file
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Export ok" message:[NSString stringWithFormat:#"This file has been added : %#",[url lastPathComponent]] delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil,nil];
[alert show];
}else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Export failed" message:[NSString stringWithFormat:#"This extention is not supported : %#",[url pathExtension]] delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil,nil];
[alert show];
}
}
return YES;
}
My issue is that when I want to export an other type of file with extension "otherExtension". I did not create data type for this extension in my app.
So I export and send an e-mail with this second type of file. The file name showed in e-mail "file.otherExtension". But, this is the issue, when I tap this mail attachement the e-mail app offers me to open it in my application. That's not what I want and, as I said, I did not create the data type for "otherExtension".
Edit : This is how I created the file type in myApp-info.plist :
If someone is interested, the issue were from the send e-mail fonction.
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init] ;
[picker setSubject:mailSubject];
[picker addAttachmentData:codedData mimeType:#"application/myApp" fileName:[filePath lastPathComponent]];
[picker setToRecipients:[NSArray array]];
[picker setMessageBody:mailBody isHTML:NO];
[picker setMailComposeDelegate:self];
[currentMainViewController presentViewController:picker animated:YES completion:nil];
By adding the mime type to mail attachment the receiving application was using it to read the file. Replacing the mime type by "nil" solved my issue.
[picker addAttachmentData:codedData mimeType:nil fileName:[filePath lastPathComponent]];
I am trying to use the built in iOS 5 Twitter framework and the TwitVid SDK to upload a video to twitter.
Steps I am taking:
1) Use TWRequest to get a signed request.
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
[accountStore requestAccessToAccountsWithType:[accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter] withCompletionHandler:^(BOOL granted, NSError *error) {
if(error) {
[[[UIAlertView alloc] initWithTitle:#"Sorry!" message:[error description] delegate:nil cancelButtonTitle:#"Okay" otherButtonTitles: nil] show];
}
else if (granted) {
NSArray *arrayOfAccounts = [accountStore accountsWithAccountType:[accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]];
if ([arrayOfAccounts count] > 0) {
ACAccount *account = [arrayOfAccounts objectAtIndex:0];
NSURL *spURL = [NSURL URLWithString:#"https://api.twitter.com/1/account/verify_credentials.json"];
TWRequest *twRequest = [[TWRequest alloc] initWithURL:spURL parameters:nil requestMethod:TWRequestMethodGET];
[twRequest setAccount:account];
NSURLRequest *signedURLRequest = [twRequest signedURLRequest];
2) Create an instance of TwitVid and fire off an upload request
TwitVid *twitVid = [[TwitVid alloc] initWithSource:#"Test" delegate:self];
[twitVid uploadWithMediaFileAtPath:moviePath offset:0 message:#"Test Message" mediaID:nil playlistID:nil vidResponseParent:nil userTags:nil geoLatitude:nil geoLongitude:nil tags:nil categoryID:nil description:#"upload test" title:#"The title" xVerifyCredentialsAuthorization:[signedURLRequest valueForHTTPHeaderField:#"Authorization"] xAuthServiceProvider:[spURL absoluteString]];
The first time I did this, I got some error back from the appropriate delegate method, and assumed it was a signing issue (I had some bugs in my code there). Now, no matter what I do, I get NOTHING in any of my delegate methods. Its not sending data, no response is received - nothing. I am at a loss of what to do. Any ideas?