googleads / googleads-mobile-ios-examples Goto Github PK
View Code? Open in Web Editor NEWgoogleads-mobile-ios
License: Apache License 2.0
googleads-mobile-ios
License: Apache License 2.0
Support Swift 3.0 and Xcode 8.0 with cocoapods?
After done with 'pod install', I got compile err: Use of unersolved identifier 'GADRequest'
Obj-C rewarded example has issue with setup it seems. Console log:
<FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=501 "(null)"
Invalid Request. Cannot determine request type. Is your ad unit id correct?
Reward based video ad failed to load.
Issue seems with line 31 in AppDelegate.m:
[GADMobileAds configureWithApplicationID:@"INSERT_APP_ID_HERE"];
And on line 103 in ViewController.m
[[GADRewardBasedVideoAd sharedInstance] loadRequest:request withAdUnitID:@"INSERT_AD_UNIT_HERE"];
Same goes for Swift version as well.
Even using only a constraint of 50 points for height, a banner view setup with kGADAdSizeSmartBannerPortrait does always only pull down the "320x50 test banner" creative. Does this mean that the smart size thing does actually not work, OR, it works but there is just no matching test creative so it sends the "next nearest match" which could be 320x50 in this case - kind of thinking? I am expecting, in portrait, a 414 point wide banner on iPhone 6 Plus, 375 points on iPhone 6, 320 on other iPhones and iPods.
FYI: I came here looking for smart sized banners as advertised on your pages. The example projects showed nothing of that, I had to setup define the kGADAdSizeSmartBannerPortrait myself. A suggestion would be to show off all possible banner sizes in your sample projects. Granted they work.
There were a few other issues stemming from too old codebases. Bitcode needed to be turned off, some battling with cocoapods, adding launch images (for the ObjC project) in order to get native resolution on iPhone 6 Plus and iPhone 6, and possibly a few more issues before it was even possible to build and run properly. You might want to fix that stuff.
I probably missed something basic but out of the box, "Module GoogleMobileAds not found" error comes up.
(doh, pod... sorry my mistake. I just don't ever liked pod)
Hi,
Our native ads located in cells. The documentation request the following line:
nativeExpressAdView.rootViewController = self
But we can't reference the UIViewController inside a cell. It will create retain cycle and it is just wrong programing
GADInterstitialDelegate: use of undeclared type"GDAIntertitial Delegate"
First I do a pod install but I can build the project.
I'm in Xcode 7.3.1
Run DFPNativeExample project.
Check only Custom Native Ad switch on.
Tap Refresh Ad.
Result in console:
2015-10-20 10:49:48.339 DFPNativeExample[50671:32868793] <GADAdLoader: 0x7fa24db8bcb0> failed with error: Request Error: Received invalid response.
Nothing changes in app.
RewardedVideoExample for Swift
Hi,
I'm implementing rewarded videos on my app and I want to let server know about the reward.
How can I get an unique identifier of the reward? Or do you recommend any other safe option?
Thank you,
Mário
I have a hard time integrating AdMob with existing project - receiving No ad to show.
all the time.
However, when I create a new project I have no problems with retrieving ads with the same code.
My main project includes Google Analytics pod, I commented out it's setup with no success.
On both existing and new project ATS is disabled.
I've tried setting IS_ADS_ENABLED
to YES
for analytics but then it shows an error that I have to include Google/Ads
in the pods file which results with target has frameworks with conflicting names: GoogleMobileAds.
When I comment out Google-Mobile-Ads-SDK
and leave Google/Ads
I get build errors.
Both projects are with target iOS >= 8.0 + Swift.
class AdViewController: UIViewController {
private var interstitial: GADInterstitial!
override func viewDidLoad() {
super.viewDidLoad()
interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
let request = GADRequest()
// Requests test ads on test devices.
request.testDevices = ["eade18b6188d6fe8214f399759097686"]
interstitial.delegate = self
interstitial.loadRequest(request)
}
}
extension AdViewController: GADInterstitialDelegate {
/// Called when an interstitial ad request succeeded.
func interstitialDidReceiveAd(ad: GADInterstitial!) {
print("interstitialDidReceiveAd")
}
/// Called when an interstitial ad request failed.
func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) {
print("interstitial:didFailToReceiveAdWithError: \(error.localizedDescription)")
}
/// Called just before presenting an interstitial.
func interstitialWillPresentScreen(ad: GADInterstitial!) {
print("interstitialWillPresentScreen")
}
/// Called before the interstitial is to be animated off the screen.
func interstitialWillDismissScreen(ad: GADInterstitial!) {
print("interstitialWillDismissScreen")
}
/// Called just after dismissing an interstitial and it has animated off the screen.
func interstitialDidDismissScreen(ad: GADInterstitial!) {
print("interstitialDidDismissScreen")
}
/// Called just before the application will background or terminate because the user clicked on an
/// ad that will launch another app (such as the App Store).
func interstitialWillLeaveApplication(ad: GADInterstitial!) {
print("interstitialWillLeaveApplication")
}
}
Still 7.8.1
You are currently using version 7.8.1 of the SDK. Please consider updating your SDK to the most recent SDK version to get the latest features and bug fixes. The latest SDK can be downloaded from http://goo.gl/iGzfsP. A full list of release notes is available at https://developers.google.com/admob/ios/rel-notes.
This is a bit strange. After updating to Xcode 7.1. I get these errors
Include of non-modular header inside framework module 'GoogleMobileAds'
Module GoogleMobileAds not found...
Sometimes I see error:
2016-11-24 15:59:57.732 Russian[36147:1904224] <Google> Unable to set adSize property. Not enough space to show ad with custom size, {726, 264}. Please use a size that fits the current screen bounds of {375, 667}.
2016-11-24 15:59:57.754 Russian[36147:1904216] <Google> Invalid Request. Ad size will not fit on screen
But I does not set ad size 726, 264
, I set 363, 132
. Looks like it's in pixels and compared to screen size in pt.
(lldb) po adSize.size
(width = 363, height = 132)
(lldb) po adSize.flags
1
(lldb) po [UIScreen mainScreen]
<UIScreen: 0x7fa990402e30; bounds = {{0, 0}, {375, 667}}; mode = <UIScreenMode: 0x61000023cfa0; size = 750.000000 x 1334.000000>>
(lldb) po self.superview
<UICollectionView: 0x7fa991875200; frame = (0 0; 375 603); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x618000250980>; layer = <CALayer: 0x6180002369a0>; contentOffset: {0, 0}; contentSize: {375, 262}> collection view layout: <UICollectionViewFlowLayout: 0x7fa9921363d0>
(lldb) po self
<AdsCell: 0x7fa99043a180; baseClass = UICollectionViewCell; frame = (6 124; 363 132); clipsToBounds = YES; layer = <CALayer: 0x6000002341c0>>
(lldb) po self.contentView
<UIView: 0x7fa99043a7f0; frame = (0 0; 363 132); gestureRecognizers = <NSArray: 0x600000258780>; layer = <CALayer: 0x6000002347e0>>
(lldb) po self.contentView.subviews
<__NSArrayM 0x600000259080>(
<UIView: 0x7fa99043aae0; frame = (0 0; 363 132); layer = <CALayer: 0x600000234420>>,
<UIActivityIndicatorView: 0x7fa99043ac80; frame = (171.5 56; 20 20); layer = <CALayer: 0x600000233860>>
)
Whenever ad load, memory increase ~20 MB
Getting this error every time, I added ATS privacy in plist file...
InterstitialExample[6790:2228703] CFNetwork SSLHandshake failed (-9806)
2017-04-11 16:31:39.331 InterstitialExample[6790] [Firebase/Core][I-NET901017] <Firebase/Network/ERROR> Encounter network error. Code, error: -1001, Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLStringKey=https://play.googleapis.com/log, NSErrorFailingURLKey=https://play.googleapis.com/log, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2103, NSLocalizedDescription=The request timed out.}
i have updated admob library to version 6.12, how to solve this error
Undefined symbols for architecture armv7:
"OBJC_CLASS$_EKEvent", referenced from:
objc-class-ref in libGoogleAdMobAds.a(GADOpener.o)
"OBJC_CLASS$_EKEventEditViewController", referenced from:
objc-class-ref in libGoogleAdMobAds.a(GADOpener.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error installing Firebase,
[!] /usr/bin/curl -f -L -o /var/folders/4r/b0y15zhs4mgfvkz6jsx7yvp00000gn/T/d20160926-21140-3ekvk9/file.tgz https://www.gstatic.com/cpdc/cc5f7aac07ccdd0a/Firebase-3.5.0.tar.gz --create-dirs --netrc-optional
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:01:15 --:--:-- 0curl: (7) Failed to connect to www.gstatic.com port 443: Operation timed out
in china!
hello!
we encountered 2 problems while testing admob reward ads.
sometimes a non-reward-video-ad is served
https://github.com/cngamegirl/cngamegirl.github.io/blob/master/admobbug.chls.zip
we always preload ads and check availability before presenting it, but sometimes the video just pause/freeze. i suspect the ads is not fully cached when it's ready to show?????
we encounter this problem on interstitial video ads too, the count-down number stops counting and then disappear when time is up
Hello,
I have some difficulties with enabling location services in SDK. I don't have any option to Allow user location or ask to allow for when I check possible permissions in settings for this app. I tried with adding location-services in Info.plist file like it is mentioned on https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html but it didn't work for me. Do you have any additional info how to include option to share location.
Thanks
After installing pods build is failed with error
ld: library not found for -lGoogleToolboxForMac
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Using cocoapods-1.2.0.beta.1 (cocoapods-1.1.1 fails to generate pods project when installing pods)
Hello,every time loadRequest is being called CPU is 100%.
in v. 7.6.0 even if the user closes the interstitial, cpu remains 100%.
At v. 7.7.0 cpu is again 100% ( all the time the ad is open) but drops when ad close.
Any idea?
When running the example project (DFPNativeExample.xcodeproj) and using Custom Native Ads, there appears to be a memory leak. Memory usage goes up upon each ad Request.
Running Xcode 6.3.2, iPhone 6 iOS 8.1.
Is this the proper place to log this?
Just making a wild guess, I assume the ad is being held in memory because impression and click logging happens async, and when looking the code to record an impression, it's a call on the AdLoader object, thus it would have to sit around in memory (again, just guessing).
The screen shots below show memory growth after requesting about 10 ads with a 10 second delay in between each ad.
When I try to run the sample app for Interstial Ad, I get error as below
Module 'GoogleMobileAds' not found for line @import GoogleMobileAds;
Regards
Ranjit
Has anyone found a clever way to install the Google Ads SDK in a swift app that uses use_frameworks!
in the Podfile?
Bumping up against this issue: CocoaPods/CocoaPods#3267
Where my error is:
[!] The 'Pods-PROJECTNAME' target has transitive dependencies that include static binaries: (/Users/tim.kelly/code//Example/PROJECTNAME/Pods/Google-Mobile-Ads-SDK/GoogleMobileAdsSdkiOS-7.6.0/GoogleMobileAds.framework)
I've issue with memory leaks. Can you help me?
https://gist.github.com/bernikowich/52c95738c8f11e9f171ad22672af59fc
Since I've added GoogleMobileAds (Interstitial or Banner) I have the following error popping out all the time.
Command failed due to signal: Segmentation fault: 11
What is going on??
Hello.
Is there any way to make the example work with UIViewController (with a tableview inside) instead of TableViewController?
I've completed my application as the example (also with the correct admob pub and google info plist from firebase) But it only shows the regular cells from my Class and it never enters at this lines of code
func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if let nativeExpressAdView = taEvent[indexPath.row] as? GADNativeExpressAdView {
let reusableAdCell = tableView.dequeueReusableCell(withIdentifier: "NativeExpressAdViewCell",
for: indexPath)
// Remove previous GADNativeExpressAdView from the content view before adding a new one.
for subview in reusableAdCell.contentView.subviews {
subview.removeFromSuperview()
}
print("test") // ITS NEVER PRINTED AS SCROLLING
reusableAdCell.contentView.addSubview(nativeExpressAdView)
// Center GADNativeExpressAdView in the table cell's content view.
nativeExpressAdView.center = reusableAdCell.contentView.center
return reusableAdCell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "locationCell", for: indexPath) as? EventsTableViewCell
let event = taEvent[indexPath.row]
cell?.configureCell(events: event as! Events)
return cell!
}
}
And i think its because of the reloaddata
that i use.
Any idea?
Hi, There,
I run this sample, can not get any ads.
is there anything wrong with the demo?
Hi Guys, could you please improve the samples for GADNativeExpressAdView, the actual example it's really a "hello world" type... for example We are having issues trying to put the view into a collection view or table view, please refer to this SO question GADNativeExpressAdView mainly because the Ad blocks the main thread while scrolling.
What should be the right approach when including GADNativeExpressAdView in this type of scenarios?
Thanks!
Cannot find an ad network adapter with the name(s): (
"com.google.DummyAdapter"
). Remember to link all required ad network adapters and SDKs, and set -ObjC in the 'Other Linker Flags' setting of your build target.
i have this game and i created 3 funcions in my gameviewcontroller and here they are
func getInterstitialAd(){
interstitial = GADInterstitial(adUnitID: "ca-app-pub-1782852253088296/5018877964")
let requestInterstitial = GADRequest()
interstitial.load(requestInterstitial)
}
func showAd() {
if (interstitial.isReady == true){
interstitial.present(fromRootViewController: GameViewController())
}else{
print("ad wasn't ready")
interstitial = createAd()
}
}
func createAd() -> GADInterstitial{
let interstital = GADInterstitial(adUnitID: "ca-app-pub-1782852253088296/5018877964")
interstitial.load(GADRequest())
return interstital
}
and in one of my scene called StartMenu , i call those function
var viewController: GameViewController!
and then i call the functions
viewController.getInterstitialAd()
viewController.showAd()
but it always returns ad not ready , and false for interstitial.isReady,
but also the getInterstitial function is always called .
can someone help with that please
Hi there,
I can see ads working properly on simulator or testing device but not on a real device.
The app was approved and it is on the AppStore.
Here is the code I'm using.
print("Google Mobile Ads SDK version: " + GADRequest.sdkVersion())
let request = GADRequest()
request.testDevices = ["XXXXXXX", kGADSimulatorID]
bannerView.adUnitID = "ca-app-pub-XXXXXX/YYYYY"
bannerView.rootViewController = self
bannerView.loadRequest(request)
Do you have any idea?
Thanks and regards!
Steps to reproduce.
Download repo.
Run "pod install"
Open "DFPInterstitialExample.xcworkspace" and put a breakpoint in
interstitial:didFailToReceiveAdWithError
Connect a device in "Airplane mode" and run the demo
The interstitial:interstitial:didFailToReceiveAdWithError: is never called.
Expected behavior:
interstitial:interstitial:didFailToReceiveAdWithError: -> should be called on connection errors (including no connection at all)
I got this error message : Error Domain=com.google.ads Code=1 "Request Error: No ad to show." UserInfo={NSLocalizedDescription=Request Error: No ad to show., NSLocalizedFailureReason=Request Error: No ad to show.}
ios code :
var nativeExpressAdView: GADNativeExpressAdView!
func displayGoogleBanner() {
var gadAdSize = GADAdSize()
let size = CGSize(width: 280,height: 250)
gadAdSize.size = size;
self.nativeExpressAdView = GADNativeExpressAdView(adSize: gadAdSize, origin: CGPoint(x:
ScreenSize.SCREEN_WIDTH/2 - 140, y: 10))
self.contentView.addSubview(nativeExpressAdView)
nativeExpressAdView.adUnitID = AppGame.googleNativeAdsBlocMappsGame
nativeExpressAdView.rootViewController = self
nativeExpressAdView.delegate = self
let request : GADRequest = GADRequest()
nativeExpressAdView.loadRequest(request)
}
i used the code from the example for ad interstitial for swift 3 , and the app can't get an add, the code runs fine but when it comes to check isReady, it prints "Ad Wasn't ready "
Why do I use this unitID: ca-app-pub-3940256099942544/1712485313 does not have any data that can provide a data test unitID?
The rewarded video ad objective-c example uses a UIAlertView to notify the user when the video add is not ready. However that was depreciated in iOS 8. UIAlertController should be used instead for iOS 8+.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.