ios7 Getting Delegate for canDisplayBannerAds - ios7

I am integrating iAd with AdMob. I want to call AdMob when iAd fails to deliver an ad. The problem I am encountering is that the basic canDisplayBannerAds = YES does not fire a delegate method when ads fail to load. If I were actually creating a banner ad I could set that delegate to self. However, here since all we have to do is call self.canDisplayBannerAds = YES; I don't understand where to set the delegate. The method for failure is:
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
However, the above is not called when iAd cannot deliver (I have the simulator set to always fail). I do have ADBannerViewDelegate set in the interface.
Do I need to actually create a banner myself to get access to this delegate and method or is there someway to get the delegate working here so that I can use the above method?

I don't know if this is what you're looking for, but at a certain point in your app you can check your view controller's displayingBannerAd boolean to see if an iAd is currently being displayed. If not, show your AdMob ads...

Related

iAd interstitial delegate methods doesn't get called

I want to use interstitial ads in my app, so I implemented all necessary delegate methods.
The problem is, if I use [self requestInterstitialAdPresentation] to show the ad, only the interstitialAdDidLoad: method gets called.
The interstitialAdActionDidFinish: methods doesn't get called...
But if I use the deprecated [self.interstitial presentFromViewController:self] to show the ad, everything works.
Is there anything new to implement to get things work ?
Thanks in advance
Ok, I resolved the problem.
Since IOS7 with its iAd Additions there's no need for an adInterstitialDelegate. The only thing to do, is preparing the ads or set the interstitialPresentationPolicy to something other than none (as you can read in the documentation) and as a last step requesting the ad using the requestInterstitialAdPresentation: method.
iOS 9.2.1, Xcode 7.2.1, ARC enabled
#Jellyjoey I confirmed, viewDidAppear is called when the ad is closed. And as you might expect, when you tap the ad, viewDidDisappear gets called.
It has to do with how you are presenting the interstitial ad:
Completing an Advertising Action
If the full-screen ad displayed the rich media ad inside your app, it
calls your delegate’s interstitialAdActionDidFinish: method after the
ad finishes. Your implementation of this method should restore any
services paused by your app when the action started.
Important: If your app was moved into the background because the
willLeave parameter was YES, then the app’s user interface is never
covered by the banner view and your app does not receive a call to
interstitialAdActionDidFinish:. However, if your interface was covered
by the banner view, your app could still be moved into the background
later, either because the advertisement launched another app or
because the user chose to do so. In all cases, if your user interface
was covered by the banner view, it is uncovered and your delegate’s
interstitialAdActionDidFinish: is invoked before your app moves to the
background. Because the app may be moving into the background, your
delegate should return quickly from its interstitialAdActionDidFinish:
method.
To view the excerpt above and the rest of the guidelines for interstitial ads:
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/iAd_Guide/Full-ScreenAdvertisements/Full-ScreenAdvertisements.html#//apple_ref/doc/uid/TP40009881-CH5-SW24
Here are two examples provided by Apple of how to use full page ads:
https://developer.apple.com/library/ios/samplecode/iAdInterstitialSuite/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010627-Intro-DontLinkElementID_2

UIViewController visible callback

I am developing an iOS application where need to do some stuff when I have Internet connection and other, when I haven't. If I haven't at some point I will show a message to the user to give me internet and come back. The question it is how to detect the following situation:
the user press the Home button twice, goes to multitasking , Settings and will connect to internet
the user comes back with multitasking to my app, but doesn't press anything
I know I will get callbacks to the AppDelegate:
- (void)applicationDidEnterBackground:(UIApplication *)application
- (void) applicationDidBecomeActive:(UIApplication *)application
but the code ( it is not started by me) it is very big, and I don't want to handle there the UIViewController needs, if there is any alternative.
My UIViewController's - (void)viewDidAppear:(BOOL)animated it isn't called when the user came back.
The breakpoint it is not hited for sure!
Any usable ideas, except in AppDelegate?
You can use the notification center to listen to applicationDidEnterBackground within the view controller:
[[NSNotificationCenter defaultCenter] addObserver: self
selector: #selector(handleEnteredBackground:)
name: UIApplicationDidEnterBackgroundNotification
object: nil];
Do this in viewDidLoad. Similarily for applicationDidBecomeActive.
Don't forget to remove yourself as an observer in viewDidUnload.
The application delegate is the correct place to be handling application state changes, but just because that is the case, it doesn't mean you must put all the logic that is triggered by the application state change in there.
Put the logic where it belongs. If it's networking code, that's not in the application delegate and it's not in the view controller, it's in a separate class. Then look into ways of tying the different parts of your application together. In most cases, notifications, KVO and the shared instance pattern are good approaches to take.

How to call webviewdidfinishload delegate method of web view in cocoa?

I am using the WebViewDidFinishLoad delegate Method of WebView, but it is not getting called. Whenever I run the application and load request in a WebView.
Please tell me, how to call the method and which delegate I need to connect with the file owner.
Any help will be appreciated.
Thanks in advance.
You said in a comment on another answer:
- (void)webViewDidFinishLoad:(WebView *)webView{ NSLog(#"hello");}
This method is not getting called.
That's because there is no such method.
WebView and UIWebView are not the same thing. The former is in the WebKit framework on the Mac; the latter is in the UIKit framework on iOS. WebView is not available on iOS and UIWebView is not available on the Mac.
UIWebView is a very stripped-down version of WebView. In particular, UIWebView has only one delegate protocol, of which webViewDidFinishLoad: is one of its methods, whereas WebView has no fewer than six delegate protocols.
webViewDidFinishLoad: only exists in the UIWebViewDelegate protocol, in the UIKit framework for iOS apps. Implementing it in a Mac application will achieve nothing, because nothing will call it.
Please tell me how to call the method …
That will do you no good, because the whole point of implementing it is to find out when a load has finished. For you to call it yourself, you would need to know when to call it—i.e., when a load has finished. To know that, you would need to be told that a load has finished by WebKit. This is, as they say in logic, begging the question.
The correct solution is to set the correct delegate to an object that conforms to the correct delegate protocol and implements the correct method. The correct delegate is the WebView's frame load delegate. Accordingly, the correct protocol is the WebViewFrameLoadDelegate protocol. The correct method within that protocol that your frame load delegate must implement is the webView:didFinishLoadForFrame: method.
Cocoa Touch programmers with the same problem (webViewDidFinishLoad: not getting called) should make sure that their UIWebView's delegate is set to the correct object. If you're setting it in code, make sure you're talking to the correct web view—i.e., that your outlet to the web view is connected (if it's in a nib or storyboard), that you're loading the nib or storyboard (if it's in one), and that you're not clobbering the value of the outlet with a different web view (one from the nib, then one created in code, or vice versa).
Try to add (And replace the myUIWebView with your UIWebView outlet name):
[myUIWebView setDelegate:self];
And in the header file, add <UIWebViewDelegate>, so you can use this methods:
-(void)webViewDidStartLoad:(UIWebView *)webView {
}
-(void)webViewDidFinishLoad:(UIWebView *)webView{
}
First Bound ResourceDelegate of webview with file Owner
(void)webView:(WebView *)sender resource:(id)identifier didFinishLoadingFromDataSource:(WebDataSource *)dataSource
This will work for me perfectly.

how to handle “sendDidFinish” in sharekit

I use sharekit with mail/twitter/facebook and I am really new to objective-c. sharekit works well and sends my images like it should.
in my app I have a screenshot function. I want the app to 'freeze' when a screenshot is taken, stopping to send any shake- or touch-event to the scene behind the sharekit-action.
in my screenshot-layer I have three buttons which call the shareItem-methods of their specified service, like
[SHKTwitter shareItem:item];
vereything works fine 'till here. but now when the sending is finished (or canceled or errored) I need the app to 'unfreeze', sharekit should tell my app that it is allowed to listen to any touch- or shake-action again.
I am sorry but I think I don't understand the concept of using the delegate here. I mean, is 'sendDidFinish' meant to be inside a delegate? and if so, how could I tell sharekit who is its delegate? or do I have to edit the send-service classes (like SHKItem or SHKFacebook) itself?
please don't downrate me for this question. I really want to get behind this mystery...
SHKTwitter inherit from SHKOAuthSharer, who inherit from SHKSharer. SHKSharer has a delegate protocol called "SharerDelegate".
So you can use an instance of SHKTwitter, then set it's delegate as :
shkTwitterInstance.shareDelegate = yourDelegateObject.
And implement the delegate method
- (void)sharerFinishedSending:(SHKSharer *)sharer;.
Try that.
EDIT (OTHER, AND MORE POPULAR, SOLUTION)
Also, you can suscribe your object to "SHKSendDidFinish" notification from SHKTwitter object.
[[NSNotificationCenter defaultCenter] addObserver:yourObject selector:#selector(theMethodthatYouWantToExecuteWhenTheNotificationIsRaised:) name:#"SHKSendDidFinish" object:shkTwitterObject];

App Crash on Working with Facebook Connect

While I'm testing my app, is an UITableViewController navigation based app, sometimes, getting back or changing the view for another, I'm getting the next crash message. I can't solve this error, I don't know what is the responsible of this. Somebody can help me?
Thanks for reading.
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
When the app has finish, XCode points this Facebook Connect method.
- (void)dialogDidSucceed:(NSURL *)url {
if ([_delegate respondsToSelector:#selector(dialogCompleteWithUrl:)]) {
[_delegate dialogCompleteWithUrl:url];
}
[self dismissWithSuccess:YES animated:YES];
}
Now the problem is solved. The best way to use the Facebook Connect SDK is to implement all the Facebook related objects into the App Delegate. When the user touch the button that allow to post into him Facebook wall (doesn't matter the UIView where the user is), you only have to call the App Delegate and get the Facebook objects that you need to call the Facebook Connect dialog. The App Delegate must be the Facebook Connect delegate for FBDialogDelegate and for FBSessionDelegate. Also, the App Delegate must implement the application: handleOpenURL: method.
Thanks to everyone for reading.