MarketingCloudSDK.Net 8.2.0.8

dotnet add package MarketingCloudSDK.Net --version 8.2.0.8                
NuGet\Install-Package MarketingCloudSDK.Net -Version 8.2.0.8                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MarketingCloudSDK.Net" Version="8.2.0.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MarketingCloudSDK.Net --version 8.2.0.8                
#r "nuget: MarketingCloudSDK.Net, 8.2.0.8"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MarketingCloudSDK.Net as a Cake Addin
#addin nuget:?package=MarketingCloudSDK.Net&version=8.2.0.8

// Install MarketingCloudSDK.Net as a Cake Tool
#tool nuget:?package=MarketingCloudSDK.Net&version=8.2.0.8                

MarketingCloudSDK.Net and SFMCSDK

.Net 7 and .Net 8 support, Android and iOS

WIKI and API:

Android Issues

to able run and compile and avoid issue

Error JAVAC0000: error: cannot access * com.salesforce.marketingcloud.* bad class file: obj/Debug/net7.0-android/lp/179/jl/classes.jar(/com/salesforce/marketingcloud/*.class) class file has wrong version 61.0, should be 55.0 Please remove or make sure it appears in the correct subdirectory of the classpath. Directory 'obj/Debug/net7.0-android/lp/179' is from 'marketingcloudsdk.aar'. (JAVAC0000) (*) javac

install JDK 17 and select it path in xamarin studio settings

fix r8 issues:

Compilation failed java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete

download latest R8 jar file

and add <AndroidR8JarPath>Platforms/Android/r8-8.2.42.jar</AndroidR8JarPath> to your csproj file inside <PropertyGroup></PropertyGroup>

Initialize iOS

AppDelegate.cs: `[Register("AppDelegate")] public class AppDelegate : MauiUIApplicationDelegate { protected override MauiApp CreateMauiApp() ⇒ MauiProgram.CreateMauiApp();

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
    SfmcManager.ConfigurePlatformSdk();
    return base.FinishedLaunching(application, launchOptions);
}

}

public static void ConfigurePlatformSdk() { // Silence Keychain Crash: // If a device is setup with FaceId or Passcode based authentication, // and if an application (with MarketingCloudSDK integrated) // accesses the Keychain when the device is in a locked state, a fatal // exception is thrown. The SDK cannot access these files due to the iOS Data // Protection mode. // https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/trouble/trouble-Keychain-crash.html

    SFMCSdk.SetKeychainAccessErrorsAreFatalWithErrorsAreFatal(errorsAreFatal: false);

    var appId = "";
    var accessToken = "";
    var serverUrl = "";
    var mid = "";

    var pushConfig = new PushConfigBuilder(appId)
        .SetAccessToken(accessToken)
        .SetMarketingCloudServerUrl(new NSUrl(serverUrl))
        .SetMid(mid)
        .SetInboxEnabled(false)
        .SetLocationEnabled(false)
        .SetAnalyticsEnabled(true)
        .SetDelayRegistrationUntilContactKeyIsSet(true)
        .Build();

    SFMCSdk.SetLoggerWithLogLevel(SFMCSdkLogLevel.Debug, new SFMCSdkLogOutputter());
    SFMCSdk.Mp.SetDebugLoggingEnabled(true);

    var configuration = new SFMCSdkConfigBuilder()
        .SetPushWithConfig(pushConfig, r => OnSdkInitialized(r))
        .Build();
    SFMCSdk.InitializeSdk(configuration);
}

static void OnSdkInitialized(SFMCSdkOperationResult result)
{
	//TODO: YAYA
}

public class Logger : SFMCSdkLogOutputter
{
    public override void OutWithLevel(SFMCSdkLogLevel level, string subsystem, SFMCSdkLoggerCategory category, string message)
    {
        Debug.WriteLine($"SFMC - Logger - OutWithLevel: {level} | {subsystem} | {category} | {message}");
        //base.OutWithLevel(level, subsystem, category, message);
    }
}`

Initialize Android

MainApplication.cs: `[Application] public class MainApplication : MauiApplication { public MainApplication(IntPtr handle, JniHandleOwnership ownership) : base(handle, ownership) { }

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();

public override void OnCreate()
{
    ConfigurePlatformSdk(this as Android.Content.Context);
    base.OnCreate();
}

}

public static void ConfigurePlatformSdk(Android.Content.Context context) { var appId = ""; var accessToken = ""; var serverUrl = ""; var mid = "";

    // Initialize logging _before_ initializing the SDK to avoid losing valuable debugging information.
    SFMCSdk.SetLogging(LogLevel.Debug, new ILogListener.AndroidLogger());
    MarketingCloudSdk.LogLevel = MCLogListener.Verbose;
    MarketingCloudSdk.SetLogListener(new IMCLogListener.AndroidLogListener());
    var mbuilder = MarketingCloudConfig.InvokeBuilder();
    mbuilder = mbuilder.SetApplicationId(appId);
    mbuilder = mbuilder.SetAccessToken(accessToken);
    mbuilder = mbuilder.SetMarketingCloudServerUrl(serverUrl);

    //TODO: get this one, it is from documentation https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/sdk-implementation/implement-sdk-google.html
    // but I have no Idea about the value of it
    //mbuilder = mbuilder.SetSenderId("<firebase sender id>");
    mbuilder = mbuilder.SetMid(mid);
    
    //required!!! will crash if no options
    mbuilder = mbuilder.SetNotificationCustomizationOptions(NotificationCustomizationOptions.Create(Android.Resource.Drawable.GalleryThumb));
    
    var sfBuilder = new SFMCSdkModuleConfig.Builder();
    sfBuilder.PushModuleConfig = mbuilder.Build(context);

    
    SFMCSdk.Configure(context, sfBuilder.Build(), new Function1Impl<SFMCSdkInitializationStatus>((result) => { var stat = result.Status == SFMCSdkInitializationStatus.InterfaceConsts.Success ? "Success" : "Failure"; Debug.WriteLine($"SFMC - OnSdkInitialized: {stat}");  }));
}

public class Function1Impl<T> : Java.Lang.Object, IFunction1 where T : Java.Lang.Object
{
    private readonly Action<T> OnInvoked;

    public Function1Impl(Action<T> onInvoked)
    {
        this.OnInvoked = onInvoked;
    }

    public Java.Lang.Object Invoke(Java.Lang.Object objParameter)
    {
        try
        {
            T parameter = (T)objParameter;
            OnInvoked?.Invoke(parameter);
            return null;
        }
        catch (System.Exception ex)
        {
            // Exception handling, if needed
        }
        return null;
    }
}`
Product Compatible and additional computed target framework versions.
.NET net8.0-android34.0 is compatible.  net8.0-ios17.2 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.2.0.8 356 10/30/2024
8.2.0.6 99 10/7/2024
8.1.2.10 622 7/12/2024
8.1.2.4 99 7/12/2024
8.1.2.3 201 5/20/2024
8.1.2.2 116 5/17/2024
8.1.1.81 150 2/28/2024
8.1.1.80 128 2/28/2024
8.1.1.79 147 2/22/2024
8.1.1.76 151 2/7/2024
8.1.1.75 162 2/7/2024