I am trying to prototype a functionality that would allow me to send an SMS in the background on Android with .NET MAUI-8.0 but I am having trouble utilizing the approach where I use partial classes.
The procedure I did was as follows:
I have a rather empty project, MauiApp3, and I added MauiApp3\PlatformServices\SmsMaster.cs to the project.
The content of this file is as follows:
namespace MauiApp3.PlatformServices
{
public partial class SmsMaster
{
public partial void Send(string recipient, string message);
public partial void SendInBackground(string recipient, string message);
}
}
I also added the same file under MauiApp3\Platforms\Android\SmsMaster.cs.
This file then contains below code:
namespace MauiApp3.PlatformServices
{
public partial class SmsMaster
{
public partial void Send(string recipient, string message)
{
throw new NotImplementedException();
}
public partial void SendInBackground(string recipient, string message)
{
throw new NotImplementedException();
}
}
}
However, I'm getting an error on the code under \PlatformServices\SmsMaster.cs
CS8795 Partial method 'SmsMaster.Send(string, string)' must have an implementation part because it has accessibility modifiers.
This hinders me from being able to call the Platform-implemented code from the shared project itself where MainPage.xaml.cs is located. I also tried a whole different approach as Julian have outlined here but I'm getting a CS0234 Error despite following the approach carefully.
Any help would be greatly appreciated.
Thank you.



Solved!
After a few minutes of posting this question, i noticed the extended error definition and it mentioned the other platforms for
iOS,macOS, and etc.I then copy/pasted the
SmsMaster.csthat i have in\Platforms\Androidinto the rest of the platforms and viola! the error is gone.The same thing was mentioned by Jason in the comment of this question, thanks for that.