Define Settings

Defining settings for a mobile application is different from a web application. A web application typically loads settings from a configuration file like appsettings.json. But a mobile application needs to be packaged and installed as a unit, including its settings. While an appsettings.json file can be included as an embedded resource, there is a better solution.

I recommend that settings be defined in a partial class. As a partial class, one file can describe the properties while the other provides the values. Each developer can have their own values file that is not checked into source control.

First create a class that defines the settings. In this class, leave instructions for other developers.

public partial class Settings
{
    // Create a file named Settings.Local.cs
    // Set the properties in the Settings constructor
    // Do not check Settings.Local.cs into source control

    // For example:
    /*
    partial class Settings
    {
        public Settings()
        {
            ReplicatorUrl = "https://repdev.jinaga.com/xxxXXXXxxxyyyyYYYyyy";
            AppleAuthUrl = "...";
            ...
        }
    }
    */

    public string? ReplicatorUrl { get; }
    public string? AppleAuthUrl { get; }
    public string? GoogleAuthUrl { get; }
    public string? AccessTokenUrl { get; }
    public string? RevokeUrl { get; }
    public string? ClientId { get; }
    public string Scope { get; } = "profile read write";
    public string CallbackUrl { get; } = "blogmaui://callback";
}

Then create a file named Settings.Local.cs. Add this file to your .gitignore file so that it is not checked into source control.

partial class Settings
{
    public Settings()
    {
        ReplicatorUrl = "https://rep.jinaga.com/xxxxyyyy";
        AppleAuthUrl = "https://rep.jinaga.com/xxxxyyyy/auth/apple";
        GoogleAuthUrl = "https://rep.jinaga.com/xxxxyyyy/auth/google";
        AccessTokenUrl = "https://rep.jinaga.com/xxxxyyyy/auth/token";
        RevokeUrl = "https://rep.jinaga.com/xxxxyyyy/auth/revoke";
        ClientId = "xxxxyyyy";
    }
}

Jinaga settings are not secret. Production settings can be checked into source control. Create another version of the values class for production settings. Keep this file outside of the project structure, and copy it into the project in the production build pipeline.

Continue With

Configure Jinaga

Jinaga is a product of Jinaga LLC.

Michael L Perry, President