marcojak / MauiMTAdmob

MIT License
115 stars 18 forks source link

IOS initialization does not work - v 1.6.4 #104

Closed andrehuhn-be closed 1 month ago

andrehuhn-be commented 1 month ago

The initialization throws an exception on IOS local device. On Android it works well. Tested on iPhone 7 and iPhone 13 Pro.

[0:] An error occurred: 'Object reference not set to an instance of an object.'. Callstack: ' at Plugin.MauiMTAdmob.MauiMTAdmob.Init(String license, String nativeAdsId, String openAdsId, Boolean enableOpenAds, Boolean tagForUnderAgeOfConsent, String testDeviceId, DebugGeography geography, Boolean initiliseConsentAtStartup) at _myapp.AppDelegate..ctor() in C:\source\repos\myapp\myapp\myapp\Platforms\iOS\AppDelegate.cs:line 28 at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args) at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)' The app has been terminated.

Steps to reproduce:

public class AppDelegate : MauiUIApplicationDelegate
{
    protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();

    public AppDelegate()
    {
        CrossMauiMTAdmob.Current.Init();
    }
}

My Workloads:

android 34.0.143/8.0.100 SDK 8.0.400, VS 17.11.35327.3 aspire 8.2.1/8.0.100 SDK 8.0.400, VS 17.11.35327.3 ios 18.0.8303/8.0.100 SDK 8.0.400, VS 17.11.35327.3 maccatalyst 18.0.8303/8.0.100 SDK 8.0.400, VS 17.11.35327.3 maui-windows 8.0.82/8.0.100 SDK 8.0.400, VS 17.11.35327.3 wasm-tools 8.0.10/8.0.100 SDK 8.0.400, VS 17.11.35327.3

Do you have any idea?

marcojak commented 1 month ago

Are you testing it on a Mac or on windows?

Admob for iOS cannot be used from windows, you need a Mac to test it

andrehuhn-be commented 1 month ago

I am developing on Windows in Visual Studio 22 and deployed it from this system directly to my both iPhones and it did not work. Do I need to deploy it via my Mac?

Shame on me. Meanwhile I found it in the readme...

Important for iOS As the package Xamarin.Google.Mobile.iOS.MobileAds doesn't work on Windows, you need a MAC to test this library. If you connect your iOS device directly to Windows and run it, the library will not work. Unfortunately, this issue doesn't depend on this library so I cannot solve this.

marcojak commented 1 month ago

Yes, you need a Mac otherwise it will not work from Windows.

andrehuhn-be commented 1 month ago

I had some issues with newest Maui workloads, after downgrading to version 8.0.402 I could test the deployment via the Mac and it works well.