Do admob custom events work for an ios app written in Swift?

283 views
Skip to first unread message

Garrett Haas

unread,
Apr 12, 2015, 7:27:29 PM4/12/15
to google-adm...@googlegroups.com

In the web interface of admob when I add a custom event I type in the name of the class, in my case it is ChartboostAdapter. I created a swift file called ChartboostAdapter with the same class name. I always get the console output,

 <Google> Cannot find Custom Event class named ChartboostAdapter.

Swift class

import Foundation
import GoogleMobileAds
class ChartboostAdapter : NSObject, GADCustomEventInterstitial {
    static var mListener:GADCustomEventInterstitialDelegate?;
    static var cAdapter : ChartboostAdapter?;
    var delegate:GADCustomEventInterstitialDelegate?;

    override init(){

    }
.../
}

Garrett Haas

unread,
Apr 13, 2015, 11:10:51 AM4/13/15
to google-adm...@googlegroups.com
Custom events apparently do have to be written in Objective-c. It worked immediately for me when I made it an objective-c class. This is definitely a feature request. Allow custom events to work in Swift.

Andrew Brogdon (Mobile Ads SDK Team)

unread,
Apr 13, 2015, 12:30:04 PM4/13/15
to google-adm...@googlegroups.com
Thanks for posting your question, and again for posting your own answer. We're working on increasing our native support for Swift, so I'll pass the details of your experience on to the engineering team.

Thanks!

-Andrew

Andrew Brogdon (Mobile Ads SDK Team)

unread,
Apr 13, 2015, 2:06:14 PM4/13/15
to google-adm...@googlegroups.com
I spoke with a couple of the engineers, and they had a suggestion for you. Because the namespacing feature in Swift relies on "mangling" class names, it could be throwing off our custom event framework.  If you're interested, you could try using the info here:


to determine the mangled name given the framework and class. Then, you could try put that into the AdMob front-end as your custom event class.

I don't know whether or not this will actually work, since we don't officially support Swift yet, but it might be worth trying!

-Andrew

David Jackman

unread,
Aug 28, 2018, 8:39:30 PM8/28/18
to Google Mobile Ads SDK Developers
Have there been any developments in this naming issue? 

I have a swift library that contains a CustomEventBanner it worked once by prepending the module name as in Module.MyCustomEventBanner, but now I am getting that dreaded message again: 

<Google> Cannot find Custom Event class named Module.MyCustomEventBanner.

mobileadssdk-a...@google.com

unread,
Aug 30, 2018, 11:42:02 AM8/30/18
to David Jackman, Google Mobile Ads SDK Developers
Hi,

Yes, have you read the documentation for example at https://developers.google.com/admob/ios/custom-events#define_a_custom_event?

Here's the relevant details:

Enter the fully qualified name of the class that implements the custom event.
If your class is implemented in Swift, you need to prefix the class name with the name of its app / framework module (for example, appName.className).
Target name is required if you have multiple targets in your project or if the project name is different from the target name. With the target name, it would look like this: appName_targetName.className. In addition, remember to replace any non-alphanumeric characters such as dashes with underscores.
For more details, see this example.

Please let us know if this is not working for you.

Regards

Sam

--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-admob-ads-sdk/e292094e-f424-4bb1-b840-39651ae70d9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages