SFMCSDK.Net 1.1.1.80

dotnet add package SFMCSDK.Net --version 1.1.1.80
NuGet\Install-Package SFMCSDK.Net -Version 1.1.1.80
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="SFMCSDK.Net" Version="1.1.1.80" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SFMCSDK.Net --version 1.1.1.80
#r "nuget: SFMCSDK.Net, 1.1.1.80"
#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 SFMCSDK.Net as a Cake Addin
#addin nuget:?package=SFMCSDK.Net&version=1.1.1.80

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

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 net7.0-android33.0 is compatible.  net7.0-ios16.1 is compatible.  net8.0-android was computed.  net8.0-android34.0 is compatible.  net8.0-ios was computed.  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
1.1.1.80 86 2/28/2024
1.1.1.79 110 2/22/2024
1.1.1.1 98 2/12/2024
1.0.3.73 93 2/7/2024