How to display iOS 6 Facebook alert view without first showing SLComposeViewController - objective-c

In iOS 6, when you create an SLComposeViewController and show it with presentViewController and you have not called isAvailableForServiceType first, you will get the "No Facebook Account" alert view which gives the user an opportunity to set up their account in Settings.
Unfortunately it also shows the native Facebook posting dialog in the background as well.
I would like to have a cleaner experience than popping up two dialogs at the same time, so is there a way to only show the "No Facebook Account" dialog on its own after checking availability with isAvailableForServiceType?
Here's basically what I'd like to do:
// Check to see if the user has a Facebook account set up...
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *vc = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler completionBlock = ^(SLComposeViewControllerResult result){
// do something when complete...
};
[vc setCompletionHandler:completionBlock];
[vc setInitialText:#"Intital text..."];
[self presentViewController:vc animated:YES completion:nil];
} else {
// No Facebook account configured yet,
// so show "No Facebook Account" alert view here.
}
Is this even possible, or will I just need to show a vanilla UIAlertView that tells the user to go to the Settings app and set up their Facebook Account?
BTW, I'm also guarding that block with a call that determines if this device even supports the use of SLComposeViewController, and if not, uses the Facebook SDK instead...

I wish it could be easy!! For now i was able to call the composeViewControllerForServiceType: method even without the account setup so it will show the alert with the settings button, hide the view but i couldn't be able to hide the keyboard!! Maybe you could find a way to reset the UITextFieldDelegate or whatevere esle to not show the keyboard...but I'm not sure! Let me know if you could figure it out!

Related

How do you get that normal style location not available in IOS?

Say I turn off location in map. I go to map. Apple would pop something and says that location is not available. When user press settings it goes to settings.
How do we pop that message?
I know I can use UIAlertView. However that message seems to be apple standard. Also when pressing settings people go to setting straight. I do not see how I can make something like that my self or can I?
It seems that Apple simply display that pop up automatically when we try to get location but don't have permission to do so.
Well, not in my case. In my case if the app doesn't have permission to do so, it'll just hang waiting for permission that never come.
The first time the app wants to use location services, the system will show that alert. The user has the choice to enable it, but that alert will not be shown again. As a developer, you also don't have the ability to show it again.
What you could do, is check the authorizationStatus on CLLocationManager:
if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorized) {
// show alert telling the user to enable location services for this app
}
You can't directly open the Settings app though.
Check the location services are enabled or not.If location services is not enabled so create a own UIAlertView with location serives massage.
if([CLLocationManager locationServicesEnabled] &&
[CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied)
{
// Show alert
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView.tag == 1)
{
// set Url
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=LOCATION_SERVICES"]];
}
}

unable to 'click' on adverts

I have the following in my applicationDidFinishLaunching method:
ADBannerView* iAdView = [[ADBannerView alloc] initWithFrame:CGRectZero];
iAdView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
[[[CCDirector sharedDirector] openGLView] addSubview:iAdView];
Ads are visible but I can't click on any of them. What am I missing?
Check out these links, it seems you don't know about all the delegate methods and setup iAd actually needs.
http://developer.apple.com/library/ios/DOCUMENTATION/UserExperience/Reference/iAd_ReferenceCollection/_index.html
http://developer.apple.com/library/ios/documentation/userexperience/Reference/ADBannerView_Ref/Reference/Reference.html
http://developer.apple.com/library/ios/DOCUMENTATION/UserExperience/Conceptual/iAd_Guide/
If you see a blank white box and an unhandled error in your console ("no delegate or delegate does not implement didFailToReceiveWithError"), then the touch isn't working because no ad has been received yet. You'll need to implement the delegate method if you want to handle the receive error.
If you wait a while, an ad will probably appear. Then you'll be able to interact with it. If not, it's possible that you haven't signed up for the iAd program yet in iTunes Connect.

customize an action of iphone home button to submit score in gamecenter

i have a button in my app a button that submit score to gamecenter and works.
this is the code:
-(void)subScore{
GKScore *scoreRepoter = [[[GKScore alloc] initWithCategory:#"123456"] autorelease];
scoreRepoter.value=100;
[scoreRepoter reportScoreWithCompletionHandler:^(NSError *error) {
if (error!=nil) {
NSLog(#"errr submitting");
}else
NSLog(#"ok!");
}];
now i'd like to submit score before app is closed with home button.
i thought to customize an action of home button (if it is possible)
or perhaps i make the same line of code in viewDidUload...or something like that...
will i be sure that that action will be performed before unloading the app?
i should make that code in dealloc method?
thanks
You can't customize behaviour of Home button directly, but iOS provides some methods in your application's delegate, by which you can control lifecycle of the application.
Method called right before the application goes to background is applicationWillResignActive: in your application's delegate (usually this method is located in AppDelegate.m file).
I think you can get needed effect by calling your method like that:
- (void)applicationWillResignActive:(UIApplication *)application {
[mygame subScore];
}
Also please note that iOS has time limit of execution for this method: you must do all saving-the-game work in less that five seconds or your application will be killed.

How to connect web url in iphone application development?

I am new to iphone application.I have 6 uiimages in a view.fifth image is facebook and sixth one is twiter.Under images,Iplaced two roundrectbuttons named as click5 and click6. My requirement is,when i click on those images,I have to go to login pages of facebook and twitter.how can i do this?can anyone send me sample example and explain it detai?
If you want to send the user to the website using Safari, you invoke the openURL: method in the UIApplication class, like this:
NSURL *facebookURL = [NSURL URLWithString:#"http://www.facebook.com"];
[[UIApplication sharedApplication] openURL:facebookURL];
When assigning a button to an action, you use the UIButton's addTarget:action:forControlEvents:, providing an event handler as action. Say you're setting this up in viewDidLoad, it might look like this:
- (void) viewDidLoad {
[myButton addTarget:self
action:#selector(btnClicked:)
forControlEvents:UIControlEventTouchUpInside];
}
/**
* Click/tap event handler for some buttons
*/
- (IBAction) btnClicked:(id)sender {
// Check which button was pressed.
if (sender == self.click5) {
// ...
}
else if (sender == self.click6) {
// ...
}
}
You know the very easiest way to do this? With the free 3rd party component ShareKit. It wraps the Facebook and Twitter (and several other social network) APIs to literally make it a three-line deal to post things.
I used it for the first time in the last app I built and I was SHOCKED at how easy to use it was.

iPhone 3.0 SDK: stacked presentModalViewController calls or in series?

Here's the scenario: if this is a user's first time logging into my web service, I present a modal login view. Upon success, the user may have multiple items in his/her account and must choose one of them before he/she can proceed with the rest of the app.
I want to put up another modal view with a picker so the user can make the choice.
All the examples I've seen of multiple modals presented are canned ones (like the email composer modal, with the people picker modal coming up over it), which is of no use because the code isn't available.
When I try putting up the login modal, then dismissing it, then presenting the picker, I get a recursion somewhere with a selector being sent to subviews being sent to subviews being sent to ....
Can anyone point me to some sample code?
I'm keeping a reference to the login view, so I figured I'd just pose the stack (well, two) modal views, then dismiss the login modal and they'd all go away (like the documentation says), but I can't seem to get this going.
Thanks in advance.
I have found that I could do this, but had to eliminate animation on the first dismiss, iff I was using animation on the 2nd presentModalViewController
ContactsViewController* controller = [[ContactsViewController alloc] ...
UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
[self.navigationController presentModalViewController:navigationController animated:YES];
[controller release], controller = nil;
and then in my delegate method that is being called from the initial modal view
[self.navigationController dismissModalViewControllerAnimated:NO]; // dismiss without animation
[self.navigationController presentModalViewController:anotherViewController animated:YES];
This behavior was observed on OS 3.0.1.