Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions source/plugin/Assets/GoogleMobileAds/Api/MobileAds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,18 @@ public static void OpenAdInspector(Action<AdInspectorError> adInspectorClosedAct
});
}

public static void HelloWorld()
{
Instance.client.HelloWorld();
}

#if GMA_PREVIEW_FEATURES
public static void HelloWorldPreview()
{
Instance.client.HelloWorldPreview();
}
#endif

internal static IClientFactory GetClientFactory() {
if (clientFactory == null) {
String typeName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,11 @@ void Preload(List<PreloadConfiguration> configurations,
/// </summary>
/// <param name="onAdInspectorClosed">Called when ad inspector UI closes.</param>
void OpenAdInspector(Action<AdInspectorErrorClientEventArgs> adInspectorClosedAction);

void HelloWorld();

#if GMA_PREVIEW_FEATURES
void HelloWorldPreview();
#endif
}
}
41 changes: 41 additions & 0 deletions source/plugin/Assets/GoogleMobileAds/Editor/BuildPostProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor.iOS.Xcode;

namespace GoogleMobileAds.Editor
{
public class BuildPostProcessor: IPostprocessBuildWithReport
{

public int callbackOrder { get { return 1; } }

public void OnPostprocessBuild(BuildReport report)
{
if (report.summary.platform != BuildTarget.iOS)
{
return;
}

string projectPath = PBXProject.GetPBXProjectPath(report.summary.outputPath);
var project = new PBXProject();
project.ReadFromFile(projectPath);
string unityFrameworkTargetGuid = project.GetUnityFrameworkTargetGuid();
string scriptingDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(
BuildTargetGroup.iOS);
bool isPreviewEnabled = scriptingDefineSymbols.Contains("GMA_PREVIEW_FEATURES");

if (isPreviewEnabled)
{
// This is equivalent to adding `-DGMA_PREVIEW_FEATURES=1` to the compiler flags.
project.AddBuildProperty(unityFrameworkTargetGuid,
"GCC_PREPROCESSOR_DEFINITIONS",
"GMA_PREVIEW_FEATURES=1");

UnityEngine.Debug.Log("GMA Preview Features enabled for iOS build.");
}

project.WriteToFile(projectPath);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ public Version GetSDKVersion()
return new Version(versionString);
}

public void HelloWorld()
{
Debug.Log("Hello from MobileAdsClient!");
}

#if GMA_PREVIEW_FEATURES
public void HelloWorldPreview()
{
Debug.Log("Hello from MobileAdsClient Preview!");
}
#endif

#region Callbacks from OnInitializationCompleteListener.

public void onInitializationComplete(AndroidJavaObject initStatus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,17 @@ public void DestroyAdInspector()
AdBehaviour.DestroyAd(dummyAd);
prefabAd = null;
}

public void HelloWorld()
{
Debug.Log("Hello from MobileAdsClient!");
}

#if GMA_PREVIEW_FEATURES
public void HelloWorldPreview()
{
Debug.Log("Hello from MobileAdsClient Preview!");
}
#endif
}
}
9 changes: 9 additions & 0 deletions source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,15 @@ internal static extern IntPtr GADUAdapterResponseInfoAdError(
internal static extern string GADUAdapterResponseInfoDescription(IntPtr error);

#endregion

[DllImport("__Internal")]
internal static extern void HelloWorld();

#if GMA_PREVIEW_FEATURES
[DllImport("__Internal")]
internal static extern void HelloWorldPreview();
#endif

}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ public void OpenAdInspector(Action<AdInspectorErrorClientEventArgs> onAdInspecto
Externs.GADUPresentAdInspector(this.mobileAdsClientPtr, AdInspectorClosedCallback);
}

public void HelloWorld()
{
Externs.HelloWorld();
}

#if GMA_PREVIEW_FEATURES
public void HelloWorldPreview()
{
Externs.HelloWorldPreview();
}
#endif

[MonoPInvokeCallback(typeof(GADUAdAvailableCallback))]
private static void AdAvailableCallback(IntPtr mobileAdsClient, IntPtr config)
{
Expand Down
8 changes: 8 additions & 0 deletions source/plugin/Assets/Plugins/iOS/TestPlugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#import <Foundation/Foundation.h>

@interface TestPlugin : NSObject

+ (void)HelloWorld;

@end
27 changes: 27 additions & 0 deletions source/plugin/Assets/Plugins/iOS/TestPlugin.h.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions source/plugin/Assets/Plugins/iOS/TestPlugin.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#import "TestPlugin.h"

@implementation TestPlugin

+ (void)HelloWorld {
NSLog(@"Hello World from TestPlugin");
}

@end
42 changes: 42 additions & 0 deletions source/plugin/Assets/Plugins/iOS/TestPlugin.m.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions source/plugin/Assets/Plugins/iOS/TestPlugin_Preview.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#import <Foundation/Foundation.h>
#import "TestPlugin.h"

@interface TestPlugin (Preview)

+ (void)HelloWorldPreview;

@end
27 changes: 27 additions & 0 deletions source/plugin/Assets/Plugins/iOS/TestPlugin_Preview.h.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions source/plugin/Assets/Plugins/iOS/TestPlugin_Preview.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#if GMA_PREVIEW_FEATURES
#import "TestPlugin_Preview.h"

@implementation TestPlugin (Preview)

+ (void)HelloWorldPreview {
NSLog(@"Hello World from TestPlugin_Preview");
}

@end
#endif
42 changes: 42 additions & 0 deletions source/plugin/Assets/Plugins/iOS/TestPlugin_Preview.m.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.