Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Tutorial: Add admob interstitial ads to your CoronaCards Windows Phone 8 app
Started by spacewolf Nov 01 2014 05:43 PM

33 replies to this topic
coronacards windows phone 8 wp8 tutorial admob advertising interstitial ads google
[TOPIC CONTROLS]
Page 2 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#26

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

First, thank you for this great tutorial.

 

Looking at the code, everything seems clear but this:

local widget = require("widget")
local preloadAdButton = widget.newButton{
    label="Preload Ad",
    labelColor = { default={1,0,0}, over={0,1,0} }, 
    fontSize = 32,  
    width=200, height=50,
    onRelease = preloadAdButton_onReleaseListener,
    x = display.contentCenterX, y = display.contentCenterY + 100,
} 

When you press the button, the LUA preloadAdButton_onReleaseListener is called.

 

Where is the code for this listener?



[TOPIC: post.html]
#27

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

It's calling a C# method in the "MainPage.xaml.cs" file.  Since Google's Ads library is a .NET library, a Lua/.NET bridge needs to be coded to communicate between the 2 languages.  This is what @spacewolf is demonstrating.

 

You should have a look at our documentation in the link below for a quick explanation of how it works.  It's pretty easy to set up and it opens up a lot of options for you.

   http://docs.coronalabs.com/daily/coronacards/wp8/communication.html



[TOPIC: post.html]
#28

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

To answer myself, to call the C# you need something like this:

 

local function adInterstitialShow()
    local result = Runtime:dispatchEvent({ name = "Native_ShowInterstitialAd" });
end


[TOPIC: post.html]
#29

hrvoje.ljubich

[GLOBAL: userInfoPane.html]
hrvoje.ljubich
  • Observer

  • 24 posts
  • Corona SDK

How to use your code with Visual Basic? All wp8 files created by project have Visual Basic's .vb extension not C#'s .cs, for e.g. MainPage.xaml.vb. Help please :)



[TOPIC: post.html]
#30

spacewolf

[GLOBAL: userInfoPane.html]
spacewolf
  • Contributor

  • 298 posts
  • Enterprise

@hrvoje.ljubich

 

The code I have provided is C# code not Visual Basic. I'm pretty sure CoronaCards only works with C# as well since their project template is in C#.

 

Why do you want to use Visual Basic?



[TOPIC: post.html]
#31

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

We actually do provide a VB.NET WP8 CoronaCards project template.  :)

When providing .NET project templates, it's considered good practice to provide templates for both C# and VB.NET since those are the most popular.NET languages.  Although, in my opinion, C# is the dominant .NET language and it's in your best interest to learn it

 

You'll need to convert and integrate @spacewolf's C# code to your VB.NET project yourself.  It's not difficult.  Other than syntax, the features supported by the 2 languages are very similar.  The only striking difference is event handling, but in my opinion (and it might sound blasphemous), VB.NET's event handling is actually better than C#'s.  You'll be using syntax such as AddHandler and RemoveHandler keywords instead of C#'s += and -= respectively.  And you can explicitly designate a method as an event handler via the "Handles" keyword.  VB.NET's syntax, while more verbose, makes it more obvious how the code works and uses really software terms for its keywords such as "Inherits", "Implements", "Handles", etc.  That aspect of the language is kind of nice.

   https://msdn.microsoft.com/en-us/library/ms172877.aspx



[TOPIC: post.html]
#32

yanuar

[GLOBAL: userInfoPane.html]
yanuar
  • Contributor

  • 256 posts
  • Corona SDK

The link for the tutorial is broken 404 :(
Anyone got the backup?

 

thanks



[TOPIC: post.html]
#33

spacewolf

[GLOBAL: userInfoPane.html]
spacewolf
  • Contributor

  • 298 posts
  • Enterprise

Sorry about that! I switched hosting providers and am trying to extract the tutorial off the old one so I can put it up again. 

 

Edit: The link should be working again!



[TOPIC: post.html]
#34

yanuar

[GLOBAL: userInfoPane.html]
yanuar
  • Contributor

  • 256 posts
  • Corona SDK

nice.. thanks spacewolf!




[topic_controls]
Page 2 of 2 1 2
 
[/topic_controls]