I'm using SCShareViewController from SoundCloud API in my project (iOS 7.0) so that the user can share your audio on SoundCloud AND on Facebook through the SoundCloud UI.
The upload in SoundCloud is working perfectly! But the share on facebook is not working =/
Does anyone can help me with this?
Is it necessary for me to create an app on facebook? Or does it already use SoundCloud's instead?
EDIT:
Here is my code:
NSURL *trackURL = [NSURL fileURLWithPath:trackPath];
SCShareViewController *shareViewController;
shareViewController = [SCShareViewController shareViewControllerWithFileURL:trackURL
completionHandler:^(NSDictionary *trackInfo, NSError *error){
if (SC_CANCELED(error)) {
NSLog(#"Canceled!");
} else if (error) {
NSLog(#"Ooops, something went wrong: %#", [error localizedDescription]);
} else {
NSLog(#"Uploaded track: %#", trackInfo);
}
}];
[self presentModalViewController:shareViewController animated:YES];
Related
I am using Twitter's fabric too login via twitter & to get user's detail. I am using below code for that.
[[Twitter sharedInstance] logInWithCompletion:^
(TWTRSession *session, NSError *error) {
if (session) {
NSLog(#"signed in as %#", [session userID]);
} else {
NSLog(#"error: %#", [error localizedDescription]);
}
}];
It is working fine when I have configured twitter account in settings of iPhone i.e. added user name & password in twitter app of iPhone.
But if that is blank & no twitter account is configured I can not login & will get the error Request failed: unauthorized (401)
Is there any way in which I can ask user to enter his/her username & password ?
Thanks in advance.
-Aakil
Okay so I figured this out for anyone that happens to find this.
Go to you developer.twitter app (their website).
Add a callback URL in the apps settings. (doesn't matter what it is)
The button will work now.
You can check like this :
if (![TWTweetComposeViewController canSendTweet]) {
NSLog(#"No Twitter Accounts");
}
if you want without going settings you need to use fabric way login. In documentation they use button, I don't know your application's lifecycle but at this point you can show this button somewhere and ask them to login maybe. here is some code from documentation :
TWTRLogInButton* logInButton = [TWTRLogInButton
buttonWithLogInCompletion:
^(TWTRSession* session, NSError* error) {
if (session) {
NSLog(#"signed in as %#", [session userName]);
} else {
NSLog(#"error: %#", [error localizedDescription]);
}
}];
logInButton.center = self.view.center;
[self.view addSubview:logInButton];
hope it helps.
I need to use SoundCloud SDK into a Swift. Does someone have experience in this?
I have problem even at the start of their integration guide: https://developers.soundcloud.com/docs/api/ios-quickstart#authentication
When, in AppDelegate, I write
var scurl: NSURL
scUrl = NSURL(string: "www.francescocrema.it")!
SCSoundCloud.setClientID(idCode,secret: secCode, redirectURL: scUrl)
when it gets executed, the app crashed with SIGABRT and no visible error!
Plus, I can't manage to translate this code to Swift
- (IBAction) login:(id) sender
{
SCLoginViewControllerCompletionHandler handler = ^(NSError *error) {
if (SC_CANCELED(error)) {
NSLog(#"Canceled!");
} else if (error) {
NSLog(#"Error: %#", [error localizedDescription]);
} else {
NSLog(#"Done!");
}
};
[SCSoundCloud requestAccessWithPreparedAuthorizationURLHandler:^(NSURL *preparedURL) {
SCLoginViewController *loginViewController;
loginViewController = [SCLoginViewController
loginViewControllerWithPreparedURL:preparedURL
completionHandler:handler];
[self presentModalViewController:loginViewController animated:YES];
}];
}
Does someone know more about SoundCloud API?
Could you help me?
I am afraid SoundCloud API is not longer maintain by its team. I would recommend you to use your own library. I am using SoundCloud API as well so I decided to create one, maybe it can be useful for you.
ABMSoundCloudAPI on Github
Your redirectURL is invalid. SCRequest requires a URL with the scheme https:
NSAssert1([[aResource scheme] isEqualToString:#"https"], #"Resource '%#' is invalid because the scheme is not 'https'.", aResource);
Your Swift presentation code might look like this:
SCSoundCloud.requestAccess { (url) in
let loginViewController = SCLoginViewController(preparedURL: preparedUrl, completionHandler: nil)
self.present(loginViewController, animated: true)
}
When I try to share on Facebook using presentOSIntegratedShareDialogModallyFrom, I can not see the app name. I use the following code:
[FBSettings setDefaultDisplayName:[[FBSettings defaultDisplayName] precomposedStringWithCanonicalMapping]];
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:[arrDetailsOfTour valueForKey:#"WebAddress"]];
params.picture = [NSURL URLWithString:[arrDetailsOfTour objectForKey:#"ImageUrl"]];
params.name = [NSString stringWithFormat:#"%#",[arrDetailsOfTour valueForKey:#"CompanyName"]];
[FBDialogs presentOSIntegratedShareDialogModallyFrom:self initialText:[NSString stringWithFormat:#"%#",[arrDetailsOfTour valueForKey:#"CompanyName"]] image:toursImageView.image url:[NSURL URLWithString:[arrDetailsOfTour valueForKey:#"WebAddress"]] handler:^(FBOSIntegratedShareDialogResult result, NSError *error) {
if(error) {
NSLog(#"Error: %#", error.description);
} else {
NSLog(#"Success!");
}
}];
but I am not able to see the app name in the post. I have put Facebook Display name in plist, but still it does not show. Please help.
Apple controls the UI for the iOS integrated dialog, and they don't show the app name. The native Facebook Share Dialogs and the web dialogs will.
I've integrate facebook invite to my adroid app,with RequestsDialogBuilder as what facebook doc said.After read their doc thoroughly for several times,I haven't found the coresponding doc about ios.And there are also docs about facebook share.How about facebook-invte?
I also found ios Sample on github.
But neither do i found sample about invite~
Maybe I have to call Graph api.
For inviting users you can use the following code after adding the facebook-sdk
[FBWebDialogs
presentRequestsDialogModallyWithSession:sharedFacebookHelper.session
message:#"Your invite message"
title:nil
parameters:nil
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User canceled.
NSLog(#"User cancelled.");
} else {
// Handle the publish feed callback
}
}
}];
I want a twitter timeline to be displayed in a View, without the user having to put your twitter account, simplemete read the tweets and hashtag, of the accounts that I have selected during the programming of the app.
Is it possible? Where do I can find info for this?
All I see includes login in twitter.
Thank you.
You can use STTwitterAPIWrapper
Firstly using Twitter you must create an app , because you must use key and secret of your app in the code.
For example :
STTwitterAPIWrapper *twitter = [STTwitterAPIWrapper twitterAPIApplicationOnlyWithConsumerKey:YourTwitterConsumerKey
consumerSecret:YourTwitterConsumerSecret];
[twitter verifyCredentialsWithSuccessBlock:^(NSString *username)
{
NSDictionary *parameters = #{#"q" : #"anyHashTag", #"result_type": #"recent", #"count": #"100"};
[twitter getSearchTweetsWithQuery:parameters successBlock:^(NSDictionary *searchMetadata, NSArray *statuses, NSString *refreshUrl) {
_refreshUrl = refreshUrl;
[self parseJSONString:statuses];
} errorBlock:^(NSError *error) {
//NSLog(#"-- error: %#", error);
}];
} errorBlock:^(NSError *error) {
//NSLog(#"--** error %#", error);
}];